[TUTORIAL] How to change a mobs melee range

Started by Wowie on

Topic category: User side tutorials

Active 2 years ago
Joined Mar 2022
Points:
440

User statistics:

  • Modifications: 0
  • Forum topics: 3
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 56
[TUTORIAL] How to change a mobs melee range

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