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

Skeletons and Creepers flee endlessly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Minecraft 15w37a
    • Minecraft 1.8.4
    • None
    • Debian Jessie amd64, Oracle Java 1.8.0_40
    • Community Consensus

      If a Skeleton/Creeper flees from a nearby wolf/cat and gets transported away (e.g. by a water stream) before reaching its destination, the 'escape mode' will lock: It will always try to walk towards the block it was heading to before being moved, no matter how far away, ignoring any obstacles such as walls, holes and other wolves/cats on the way.

      The setup you see in the screenshots illustrates the bug. The skeletons get spawned and run away from the wolf to the right. Using trap doors, they are tricked to fall into the water stream and get transported away to the far right. Notice how they fight the current, apparently still in 'escape mode', however without any path or visual contact to the wolf they are running from. As soon as they drop to the floor, they run straight back to the left, ignoring the other wolves on their way. When they reach the block below the water source they initially fell on (red marker), they start jumping and spinning. Finally, after some time, normal AI kicks back in and they stop jumping and eventually wander off.

      Exactly the same applies to creepers and cats (see fourth screenshot). Notice that if you were to dig a hole (to the void) in their way, they would walk into it, as they would walk straight against any wall/block you place between the drop point and the red marker. Also note that this issue seems similar to MC-8701, however I wasn't able not reproduce the bug without wolves/cats as shown there.

      Apparently, the mobs never even realize that they move away from their original path. It seems like this 'escape route' (i.e. to a block on the platform to the far left) is calculated as soon as they realize the presence of the wolf/cat. They then start walking from block to block of the route, but seem unaware that their Y-Position changes as they fall, so they continue walking towards the next block of the escape route. The water pushes them in the opposite direction no matter how hard they fight the current, and so they just keep on running endlessly.

      This is a severe issue in scenarios where said mobs are automatically directed or separated using their AI, i.e. in mob farms/sorters. I stumbled upon this in a survival world where the mobs get transported ~40 blocks away from an AI-based farm (which works like the setup in the screenshots). Took quite some time to figure out why they keep hugging a solid stone wall!

      Update:
      I have been digging into the code using MCP, apparently there is a method that makes Creepers and Skeletons repeatedly check whether they should keep on running (EntityAIAvoidEntity.continueExecuting()), however it only cancels if the target block is reached or escape path becomes unavailable due to being stuck:

      EntityAIAvoidEntity.java
      public boolean continueExecuting() {
             return !this.entityPathNavigate.noPath();
      }
      

      One could simply extend the condition to also check if the distance to the next PathPoint on the route (i.e. the block right in front of the mob) is within a reasonable range: The square distance should not exceed 2 blocks, and even in cases of extreme server lag will probably never exceed 10 blocks:

      EntityAIAvoidEntity.continueExecuting()
      if (this.entityPathNavigate.noPath()) {
              return false;
      }
      Vec3 p = this.entityPathEntity.getPosition(this.theEntity);
      return this.theEntity.getDistanceSq(p.xCoord, p.yCoord, p.zCoord) < 10.0D;
      

        1. 2015-04-29_12.40.40.png
          2015-04-29_12.40.40.png
          224 kB
        2. 2015-04-29_12.40.48.png
          2015-04-29_12.40.48.png
          224 kB
        3. 2015-04-29_12.40.57.png
          2015-04-29_12.40.57.png
          227 kB
        4. 2015-04-29_13.56.41.png
          2015-04-29_13.56.41.png
          227 kB

            ProfMobius ProfMobius (Thomas Guimbretiere)
            rome Roman Quiring
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: