How do you testfor
a player holding a stick named Rainbow Stick
and have the lore The best stick!
in version 1.12?
Minecraft – How to testfor a custom item in player off hand 1.12 version
minecraft-commandsminecraft-java-edition
Related Topic
- Minecraft Commands – How to Testfor a Player Holding an Item and Give Them an Effect in Minecraft
- Minecraft Java Edition – How to Test for a Dropped Item Using Minecraft Commands
- Minecraft – how to testfor a player that selected an item
- Minecraft – How to test for a player wearing specific armor
- Minecraft – Testfor selected item
- Minecraft – How to detect if a player has no item selected in his hand
Best Answer
Didn't have access to Minecraft when I posted the comment, so just to finalize this question again as answer...
The part to access the offhand slot is
Slot:-106b
so the command is as follows:/testfor @p {Inventory:[{Slot:-106b,id:"minecraft:stick", tag:{display:{Name:"Rainbow Stick", Lore:"The best stick!"}}}]}
As of 1.12 it is required to encase Strings with
" "
if they contain non-whitelisted characters (including:
and spaces). This answer explains it.