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

MC-263410 Spiders, cave spiders, wolves, cats and ocelots can ignore honey blocks and jump when they attack Open MC-163856 Foxes can ignore honey blocks and jump when preying Open MC-163851 Some mobs can auto-jump when on a honey block Open MC-253479 Magma Cubes can still jump on honey blocks Reopened MC-266480 Breeze can jump on top of honey blocks Resolved

Attachments

Comments 8

Can confirm in 20w51a.

Can confirm in 21w05b.

Can confirm in 21w07a.

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, , 26.1.2, 26.2 Snapshot 3, 26.2 Release Candidate 2, 26.2, 26.3 Snapshot 2

Retrieved