How do I change the damage of my mob's ranged attack?

Started by BountyHunter29 on

Topic category: Help with modding (Java Edition)

Last seen on 10:32, 12. Apr 2017
Joined Sep 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I change the damage of my mob's ranged attack?
Fri, 04/07/2017 - 09:34 (edited)

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!

Edited by Klemen on Fri, 04/07/2017 - 09:34
Last seen on 14:19, 6. Aug 2021
Joined Jul 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm wanting to know the same
Fri, 04/07/2017 - 21:53

I'm wanting to know the same thing but I don't know any java so I'm not much use to you sorry.

Last seen on 10:32, 12. Apr 2017
Joined Sep 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Do not worry, someday someone
Sat, 04/08/2017 - 08:53

Do not worry, someday someone will answer to us.

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
entityarrow.setDamage
Sat, 04/08/2017 - 22:37

entityarrow.setDamage(WhateverValue);

Last seen on 14:19, 6. Aug 2021
Joined Jul 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thank you!
Sun, 04/09/2017 - 09:28

Thank you!

Last seen on 14:19, 6. Aug 2021
Joined Jul 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:entityarrow.setDamage
Sun, 04/09/2017 - 09:30

@#3 Can you please help me fix the bug where all the textures go missing when I try to export my mod please?

Last seen on 14:19, 6. Aug 2021
Joined Jul 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Quick question. Where do I
Sun, 04/09/2017 - 10:08

Quick question. Where do I put the entityarrow.setDamage(50); ? 

Last seen on 10:32, 12. Apr 2017
Joined Sep 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@the sloth
Sun, 04/09/2017 - 21:09

@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!

Last seen on 14:19, 6. Aug 2021
Joined Jul 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
oh, okay thank you. 
Sun, 04/09/2017 - 22:51

oh, okay thank you. 

Last seen on 09:51, 9. Feb 2024
Joined Nov 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can you explain me how i can…
Fri, 10/12/2018 - 19:37

Can you explain me how i can change the mob range damage? Please