Topic category: Help with Minecraft modding (Java Edition)
Hello everyone! As the title says, I am creating a mob that uses a ranged attack, the projectile is an arrow but rendered as a Popped chorus fruit.
Well, the problem is that I do not know how to change the damage the "arrow" does to the target.
I am not an expert in Java (I barely understand it) and I tried writing things in the code like: this.setDamage = 20D and somethings like that, but I always get recompilation errors.
These are the projectile's parts of the code:
First one:
public static class EntityArrowCustom extends EntityTippedArrow {
public EntityArrowCustom(World a) {
super(a);
}
public EntityArrowCustom(World worldIn, double x, double y, double z) {
super(worldIn, x, y, z);
}
public EntityArrowCustom(World worldIn, EntityLivingBase shooter) {
super(worldIn, shooter);
}
}
Second one:
public void attackEntityWithRangedAttack(EntityLivingBase target, float flval) {
EntityArrowCustom entityarrow = new EntityArrowCustom(this.world, this);
double d0 = target.posY + (double) target.getEyeHeight() - 1.1;
double d1 = target.posX - this.posX;
double d2 = d0 - entityarrow.posY;
double d3 = target.posZ - this.posZ;
float f = MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F;
entityarrow.setThrowableHeading(d1, d2 + (double) f, d3, 1.6F, 12.0F);
this.world.spawnEntity(entityarrow);
}
In conclussion, what do I have to do in order to, for example, increase the damage dealt by the mob when it shoots?
Thanks for reading!
I'm wanting to know the same thing but I don't know any java so I'm not much use to you sorry.
Do not worry, someday someone will answer to us.
entityarrow.setDamage(WhateverValue);
Thank you!
@#3 Can you please help me fix the bug where all the textures go missing when I try to export my mod please?
Quick question. Where do I put the entityarrow.setDamage(50); ?
@the sloth
In this part of the code:
public void attackEntityWithRangedAttack(EntityLivingBase target, float flval) {
EntityArrowCustom entityarrow = new EntityArrowCustom(this.world, this);
double d0 = target.posY + (double) target.getEyeHeight() - 1.1;
double d1 = target.posX - this.posX;
double d2 = d0 - entityarrow.posY;
double d3 = target.posZ - this.posZ;
float f = MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F;
entityarrow.setThrowableHeading(d1, d2 + (double) f, d3, 1.6F, 12.0F);
this.world.spawnEntity(entityarrow);
}
@Nuparu00
Thanks for all!
oh, okay thank you.
Can you explain me how i can change the mob range damage? Please