[TUTORIAL] How to change a mobs melee range

Started by Wowie on Thu, 08/18/2022 - 22:33

Topic category: User side tutorials

Last seen on 07:30, 24. Sep 2022
Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
[TUTORIAL] How to change a mobs melee range
Thu, 08/18/2022 - 22:33

Step 1. Right click on your mob element and select "Open mod element in code editor" then select "YourMobsName"Entity.java

 

Step 2. Look for this piece of code

@Override
    protected void registerGoals() {
        super.registerGoals();
        this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.2, false) {
            @Override
            protected double getAttackReachSqr(LivingEntity entity) {
                return (double) (4.0 + entity.getBbWidth() * entity.getBbWidth());
            }
        });

The 4.0 represents the melee range and increasing will increase your mobs melee range similar to ravager

Step 3. Save and lock code