Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-225657

Pufferfish stays inflated when an axolotl is playing dead

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 21w19a, 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
    • Confirmed
    • Mob behaviour
    • Low
    • Gameplay

      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 Thumpbacker
      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;
               }
            };
      

        1. 2021-05-16_07.47.10.png
          373 kB
          [Mod] Anthony Cicinelli
        2. MC-225657.mp4
          5.08 MB
          [Mod] Avoma

            Unassigned Unassigned
            Thumpbacker [Mod] Anthony Cicinelli
            Votes:
            7 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              CHK: