Foxes do not stop sitting or sleeping when pulled by a lead
If the player attaches a lead to a fox that is either sittingor sleeping, the fox will not transition to the standing position.
Steps to Reproduce:
- Summon a sitting/sleeping fox:
/summon fox ~ ~ ~ {Sitting:1b}/summon fox ~ ~ ~ {Sleeping:1b} - Put a lead on it
- Pull the entity away from it's original position
Observed Results:
The fox will remain sitting/sleeping and appear to be dragged across the ground.
Expected Results:
The fox would properly stand up before being pulled by a lead.
Screenshots/Videos:
Code Analysis / Fix:
One way to fix the issue is inside the 'tick()' method of the fox, we check to see if the fox is leashed, and if the leash owner is a player. If both conditions are met, set the fox's sleeping and sitting state to false.
Class: net\minecraft\world\entity\animal\Fox.java - Method: tick()
public void tick() { super.tick(); if (this.isEffectiveAi()) { boolean flag = this.isInWater(); if (flag || this.getTarget() != null || this.level().isThundering()) { this.wakeUp(); } if (flag || this.isSleeping()) { this.setSitting(false); } // FIX START Entity entity = this.getLeashHolder(); if (this.isLeashed() && entity instanceof Player) { this.setSitting(false); this.wakeUp(); } // FIX END if (this.isFaceplanted() && this.level().random.nextFloat() < 0.2F) { BlockPos blockpos = this.blockPosition(); BlockState blockstate = this.level().getBlockState(blockpos); this.level().levelEvent(2001, blockpos, Block.getId(blockstate)); } } . . . }