mojira.dev
MC-310856

Mobs spawned by players ignore the `last_hurt_by_mob` NBT tag set via `/data modify` right when spawned for 100 ticks

When a mob is spawned via a player-initiated action (either a player-entered /summon command or a player right-clicking a spawn egg), and its last_hurt_by_mob NBT tag is written via  /data modify on the exact same tick it spawns, the mob's AI ignores the written value for 100 game ticks (5 seconds):

  • Although /data get confirms that last_hurt_by_mob contains a valid, alive target UUID, the mob's AI does not respond to it.

  • The /execute on target subcommand fails to select any target during this period.

This behavior only occurs when the spawning action is initiated by a player. When the identical /data modify is applied to mobs spawned via non-player sources (command blocks, dispensers, functions), the AI responds immediately.

The following observations have been consistently reproduced:

  1. The /data modify write is successful — /data get confirms the tag contains the correct UUID.

  2. The AI ignores this value for exactly 100 ticks unless interrupted.

  3. The AI responds immediately if:

    • The tag is manually removed (/data modify entity ... last_hurt_by_mob set value {})

    • The tag is cleared by vanilla's 100-tick auto-clear mechanism (then re-written by the tick command)

    • The mob takes native damage from an attacker (e.g., melee attack, arrow) — based on testing, these are the types of damage that have been observed to overwrite last_hurt_by_mob and trigger an AI response

This indicates that the AI only begins respecting last_hurt_by_mob after the tag has undergone a "state change" (removal or overwrite by an attacker).

Trigger Condition Analysis:

Through systematic testing, the trigger condition has been narrowed down to a single factor: the spawning action must be initiated by a player.

Test Case

Spawning Initiated By

Command Executor

AI Ignores for 100 Ticks?

Player enters /summon in chat

Player

Player

✅ Yes

Player right-clicks spawn egg

Player

Player

✅ Yes

Command block runs /summon

Command block

Command block

❌ No

Command block runs execute as @p run summon

Command block

Player (via as)

❌ No

Command block runs execute at @p run summon

Command block

Command block

❌ No

Dispenser ejects spawn egg

Dispenser

Dispenser

❌ No

Key finding: The trigger is not whether the executor (@s) is a player, but whether the spawn was initiated by a player. When a command block uses execute as @p, the executor becomes a player, but the spawn is still initiated by the command block — and the AI responds immediately.

Comparative Test: last_hurt_by_mob vs angry_at:

To determine whether this issue affects all AI-related NBT tags or is specific to last_hurt_by_mob, the following comparative test was conducted:

NBT Tag

Mob

Player-Initiated Spawn

AI Ignores for 100 Ticks?

last_hurt_by_mob

Pillager / Zombie

✅

✅ Yes

angry_at

Zombified Piglin

✅

❌ No

Test command for angry_at:

execute as @e[type=zombified_piglin] unless data entity @s angry_at at @s if entity @e[type=#raiders,distance=..16] run data modify entity @s angry_at set from entity @n[type=#raiders,distance=..16] UUID

Test command for last_hurt_by_mob:

execute as @e[type=#undead,type=!zombified_piglin] unless data entity @s last_hurt_by_mob at @s if entity @e[type=#raiders,distance=..16] run data modify entity @s last_hurt_by_mob set from entity @n[type=#raiders,distance=..16] UUID
execute as @e[type=#raiders] unless data entity @s last_hurt_by_mob at @s if entity @e[type=#undead,distance=..16] run data modify entity @s last_hurt_by_mob set from entity @n[type=#undead,distance=..16] UUID

Attachments

Comments 1

Thank you for helping us improve Minecraft! We saved your files:

[media]

AnonAya09081227

(Unassigned)

Confirmed

Platform HC

Low

Commands

26.2

Retrieved