An Enderman holding a dirt block can be summoned using the command
summon enderman ~ ~ ~ {carried:"minecraft:dirt"}
As you would expect, this summons an Enderman holding a dirt block (see also MC-94027). However if you try this command:
/testfor @e {carried:"minecraft:dirt"}
the enderman will not be found by the command.
This is because the block type is stored using the old id system (dirt is stored as 3) and because the tag is a short you have to append s
:
/testfor @e {carried:3s}
Linked issues
is duplicated by 1
relates to 2
Comments 11
@Conor Mcs. This won't work because the tag, as I said above, is stored as a number string. Please test before you suggest 🙂
Inspect data of Enderman before doing anything:
/entitydata @e[type=Enderman] {}
You should see that problem.
Well, in 1.9 entitydata sets 80s instead of "minecraft:snow" (I used provided command)
Everything else is confirmed for 1.9
Confirmed for 17w46a Snapshot, but now the commands to reproduce are this:
/summon enderman ~ ~ ~ {carried:"minecraft:dirt"}
/execute as @e[type=enderman,nbt={carried:"minecraft:dirt"}] run say enderman with dirt
/execute as @e[type=enderman,nbt={carried:3s}] run say enderman with dirt
Try
/entitydata @e {carried:"minecraft:dirt"}