mojira.dev
MC-102965

Walking mobs don't use pathfinding when using NoGravity tag

Mobs which have to walk to attack or flee from the player don't seem to move anymore when they are using the NoGravity-tag. The only mob able to move and attack the player is the skeleton.

What I expected to happen was...:
The mobs would float in the air and at least try to attack me.

What actually happened was...:
They just stand/float on their spot and don't move.

Steps to Reproduce:

  1. Put up a repeating commandblock with the command

    execute as @e run data merge entity @s {NoGravity:1b}
  2. Activate the commandblock

  3. Spawn in some zombies

  4. Switch into survival mode

  5. Notice how they don't try to attack you

Note: If you spawn in zombies before you switch on the commandblock and they try to attack you and THEN you activate the commandblock, they will suddenly spin in their spot. If you walk to them they will hit you once and get knocked back, however afterwards they won't deal damage anymore.

Note 2: If you move near creepers, they will still explode.

Code analysis

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

Attachments

Comments 16

Seems like only Zombies are affected by this. I tested a few mobs, and these are the mobs that still move:

  • Slime

  • Magma Cube

  • Bat

  • Shulker Bullet

  • Potions

  • Slime

  • Skeletons Strafing

  • Rabbits when punched

  • Horses when trying to tame them

  • XP Orbs

Don't all these mobs use a slightly different version of walking? Because I thought ocelots and spiders were also affected...

So I decided I would try all mobs you could spawn with spawn eggs. The following mobs are affected and don't move.. If something was interesting about them, I noted it.
-Zombies
-Polar Bears
-Spiders
-Creepers
-Endermen (However they still teleport if there's a projectile about to hit them, sometimes they teleport when they take fire damage, they teleport when suffering rain damage and I also observed them teleporting when trying to follow you. But NOT if hit by a player)
-Zombie Pigmen
-Silverfishes
-Cave Spiders
-Witches
-Endermites
-Pigs and sheeps even if trying to lure them with their respective food (Carrots and wheat) --> Cows and Chickens too, I think
-Horses (However they CAN move if you try to tame them like Tan Chin Cheern said. However after they move for a while they suddenly begin to spin around)
-Wolves
-Mooshrooms
-Ocelots
-Rabbits (However if you punched them they were able to slide around for a while, like Tan Chin Cheern said)
-Villagers

To test this I just spawned the mobs in and went into survival mode to try to get them to attack me or I punched them to make them escape.

Also thanks for your testing, Tan Chin Cheern. 🙂

Confirmed for 16w40a, tested it yesterday with a NoGravity-Silverfish.

"NoGravity" seems to behave again like before the introduction of "NoAI", as if it would additionally make the entities have a "NoAI".
Would be great if both could be divided again }=)

I haven't tested all mobs, so I don't know if the list of affected mobs in the comments is still up to date.

Something interesting I noticed when testing: Spiders are now able to attack you, even when having the NoGravity-tag. However, zombies still weren't able to move aswell as Creepers.

6 more comments

Can confirm in 21w11a.

I can confirm this in behavior in 1.18.2 and 22w17a. Here's a code analysis of this issue.

The following is based on a decompiled version of Minecraft 1.18.2 using MCP-Reborn. 

Code Analysis:

net.minecraft.world.entity.ai.navigation.GroundPathNavigation.java

public class GroundPathNavigation extends PathNavigation {
   ...
   protected boolean canUpdatePath() {
      return this.mob.isOnGround() || this.isInLiquid() || this.mob.isPassenger();
   }
   ...

If we look at the above class, we can see that walking mobs can only update their pathfinding if they're on the ground, in liquid, or are passengers. Since the isOnGround() boolean returns "false" when a mob has their "NoGravity" tag set to "1b", they cannot update their pathfinding, thus resulting in the issue here.

Can confirm in 1.19.

Can confirm in 1.19.2.

Can confirm in 24w44a. Also would like to request ownership of this report to maintain it.

Block twenty-eight

sof

(Unassigned)

Confirmed

Commands, Mob behaviour

AI, NoGravity, movement, pathfinding, walking

Minecraft 1.10 Pre-Release 1, Minecraft 1.10, Minecraft 1.10.2, Minecraft 16w35a, Minecraft 16w36a, ..., 22w17a, 1.19, 1.19.2, 24w44a, 1.21.4

Retrieved