Mojira Archive
MC-225657

Pufferfish stays inflated when an axolotl is playing dead

The Bug

A pufferfish will stay inflated when an axolotl is playing dead. This can cause the pufferfish to idly swim next to a playing dead axolotl and kill it.

To Reproduce

  1. Summon an axolotl playing dead using the command
    /summon minecraft:axolotl ~ ~ ~ {Brain:{memories:{"minecraft:play_dead_ticks":{value:1000}}}}
  2. Spawn a pufferfish next to it.

Observed Result

The pufferfish will inflate and poison the axolotl.

Expected Result

Pufferfish should not attack axolotls whilst they're playing dead.

Code Analysis & Fix

Code Analysis done by [Mod] Anthony Cicinelli
The reason the pufferfish is inflating is because no check is happening if the axolotl is playing dead or not in the Scary_Mob predicate. Adding a check in the predicate fixes the issue.

Current Code

net/minecraft/world/entity/animal/Pufferfish.java
   public class Pufferfish extends AbstractFish {
      private static final EntityDataAccessor<Integer> PUFF_STATE = SynchedEntityData.defineId(Pufferfish.class, EntityDataSerializers.INT);
      int inflateCounter;
      int deflateTimer;
      private static final Predicate<LivingEntity> SCARY_MOB = (p_29634_) -> {
         if (p_29634_ instanceof Player && ((Player)p_29634_).isCreative())) {
            return false;
         } else {
            return p_29634_.getType() == EntityType.AXOLOTL || p_29634_.getMobType() != MobType.WATER;
         }
      };

Fixed Code

net/minecraft/world/entity/animal/Pufferfish.java
   public class Pufferfish extends AbstractFish {
      private static final EntityDataAccessor<Integer> PUFF_STATE = SynchedEntityData.defineId(Pufferfish.class, EntityDataSerializers.INT);
      int inflateCounter;
      int deflateTimer;
      private static final Predicate<LivingEntity> SCARY_MOB = (p_29634_) -> {
         //Check if an axolotl isPlayingDead Fixes MC-225657
         if (p_29634_ instanceof Player && ((Player)p_29634_).isCreative() || p_29634_ instanceof Axolotl && ((Axolotl)p_29634_).isPlayingDead()) {
            return false;
         } else {
            return p_29634_.getType() == EntityType.AXOLOTL || p_29634_.getMobType() != MobType.WATER;
         }
      };

Unresolved

[Mod] Anthony Cicinelli

2021-05-16, 05:49 PM

2024-08-02, 07:26 PM

6

2

Confirmed

Low

Gameplay

Mob behaviour

axolotl, pufferfish

21w19a - 1.2121w19a, 1.17, 1.17.1, 1.18 Release Candidate 3, 1.18, 22w06a, 22w18a, 1.19.2, 1.19.3, 23w05a, 1.19.4, 1.20, 1.20.1, 1.21

-