mojira.dev
MC-299568

Zombies and zombified piglins reset fall_distance when a turtle egg they are pathing to is broken or becomes inaccessible

When a zombie or zombified piglin is pathing towards a turtle egg and falling, breaking or placing a block above the egg resets the entity’s fall_distance tag.

To replicate:

  1. Setup a turtle egg surrounded by trapdoors so that zombified piglins will path to it and fall.

  2. Spawn a zombified piglin, after it jumps to the egg and is falling, tick freeze the game and look at the entity’s data.

  3. Break the turtle egg, advance the game by 1 or 2 ticks, then look at the entity’s data again.

Observed Result:

The entity’s fall_distance tag resets, forgetting how far the entity has fallen already.

Expected Result:

The fall_distance tag should continue progressing. If this is done in a gold farm, the zombified piglins can survive a normally fatal fall.

Attachments

Comments 2

Can confirm.

[media]

Looking at the code for 1.27.1, the process is not very complex, but spans across many classes. In short the Zombie entity class, has the behavioural goal class ZombieAttackTurtleEggGoal, which implements the egg breaking. This is a subclass of RemoveBlockGoal. There I found:

//net.minecraft.world.entity.ai.goal.RemoveBlockGoal
@Override
    public void stop() {
        super.stop();
        this.removerMob.fallDistance = 1.0;
    }

This function is called once the goal is not active any more. In this example that is when the turtle eggs are broken or inaccessible. Here we can see this sets the fall distance to 1, which can be confirmed with the /data command ingame and thus explains the issue.

Interestingly, I made another discovery while looking at the code. For context, this bug was found while trying to find the reason, why zombified piglins where rarely surviving in a fall damage farm. In the superclass of the RemoveBlockGoal class:

//net.minecraft.world.entity.ai.goal.MoveToBlockGoal
@Override
    public boolean canContinueToUse() {
        return this.tryTicks >= -this.maxStayTicks && this.tryTicks <= 1200 && this.isValidTarget(this.mob.level(), this.blockPos);
    }

This function is called every tick. If it returns false, the goal stops. So in this context, the zombie fall distance gets set to 1. Relevant here is the second conditon that is checked: this.tryTicks <= 1200. That means after 1200 ticks or 60 seconds, the function returns false, the goal is not active anymore and the fall distance is set to 1. For example:

A zombified piglin (or any other type of zombie) spawns in range of turtle eggs, it walks towards them and takes a long time to do so for some reason. As it reaches the eggs, it falls into the farm and mid fall the 1200 ticks are reached, the turtle egg goal will not be active anymore. Thus the fall distance is set to 1, by the stop function of the RemoveBlockGoal class and the zombified piglin will survive the deadly fall.

In my eyes this is not a seperate issue, as the underlying problem is in both cases the fall distance reset. But it is a relevant consequence of it.

Birder24

(Unassigned)

Confirmed

Gameplay

Normal

Mob behaviour

1.21.7, 1.21.8, 25w31a, 25w32a, 25w34b

Retrieved