mojira.dev
MC-163853

Some aquatic mobs on the honey block can jump because of the stranding

The bug

Some aquatic mobs on the honey block can jump because of the stranding.

Affected mobs

  • Cod

  • Salmon

  • Pufferfish

  • Tropical fish

  • Dolphin

  • Guardian

  • Elder guardian

  • Tadpole

Code analysis

Code analysis by @unknown can be found in this comment.

Linked issues

Attachments

Comments 7

Can confirm in 20w51a.

Can confirm in 21w05b.

Can confirm in 21w07a.

Video attached.

Can confirm in 1.18.1.

Can confirm in 1.18.2.

Code analysis / Fix (MCP 1.20.1):

After the game checks if any one of these entities is not in water, it applies modification to their DeltaMovement to make them jump. The issue comes from the fact that the 'y' value is only set as a simple double or float, and never modified depending on what block the entity is above (in this case, honey).

One possible solution for this (probably would need tuning), is to multiply the y delta movement by the "getBlockJumpFactor()" gotten from block below the entity. (This is what is done for slimes and magma cubes as well)

Guardian.class

net.minecraft.world.entity.monster/Guardian.java / aiStep()
else if (this.onGround()) {
            this.setDeltaMovement(
                    this.getDeltaMovement().add(
                            ((this.random.nextFloat() * 2.0F - 1.0F) * 0.4F),
FIX --->                    0.5D * this.getBlockJumpFactor(),
                            ((this.random.nextFloat() * 2.0F - 1.0F) * 0.4F)
                    ));
            this.setYRot(this.random.nextFloat() * 360.0F);
            this.setOnGround(false);
            this.hasImpulse = true;
         }

AbstractFish.class

net.minecraft.world.entity.animal/AbstractFish.java aiStep()
public void aiStep() {
      if (!this.isInWater() && this.onGround() && this.verticalCollision) {
         this.setDeltaMovement(this.getDeltaMovement().add(
                 ((this.random.nextFloat() * 2.0F - 1.0F) * 0.05F),
FIX --->         0.4F * this.getBlockJumpFactor(),
                 ((this.random.nextFloat() * 2.0F - 1.0F) * 0.05F)));
         this.setOnGround(false);
         this.hasImpulse = true;
         this.playSound(this.getFlopSound(), this.getSoundVolume(), this.getVoicePitch());
      }
      super.aiStep();
   }

Dolphin

net.minecraft.world.entity.animal/Dolphin.java / tick()
if (this.onGround()) {
               this.setDeltaMovement(this.getDeltaMovement().add(
                       ((this.random.nextFloat() * 2.0F - 1.0F) * 0.2F),
FIX --->               0.5D * this.getBlockJumpFactor(),
                       ((this.random.nextFloat() * 2.0F - 1.0F) * 0.2F))
               );
               this.setYRot(this.random.nextFloat() * 360.0F);
               this.setOnGround(false);
               this.hasImpulse = true;
            }

This is the behavior the fix achieves:

[media]

[Mod]Les3awe

(Unassigned)

Confirmed

Gameplay

Low

Mob behaviour, Parity

aquatic, honey_block, jump, mob, stranding

19w42a, 19w44a, 19w45a, 19w45b, 19w46a, ..., 25w09b, 1.21.5 Release Candidate 1, 1.21.5, 25w17a, 1.21.6 Pre-Release 3

Retrieved