1

I'm trying to test if a player has an item named "sunny", and if they do to have it turn into a shulker box.
If you could include the shulker box having a torch named "sunny" that would be very much appreciated too.

The command I tried was this:

execute if entity @p[nbt={Items:[{id:"!minecraft:torch"}]},display:{Name:'{"text":"Sunny"}'}] run setblock ~ ~2 ~ minecraft:blue_shulker_box

But it said display option was not an option.

1 Answer 1

2
/execute if entity @p[nbt={Inventory:[{id:"minecraft:torch",Count:1b,tag:{display:{Name:'{"text":"Sunny"}'}}}]}] run setblock ~ ~2 ~ minecraft:blue_shulker_box

I tested this in-game and it works fine.

6
  • 1
    What about the custom name? The question had data for that, but you did not include any mention to it. Mar 23, 2022 at 3:46
  • 1
    Blue Robin, I tried what you said but... 1 ExpertCoder14 is right... And 2, I need for it to test if the player has the item, not... Not having the item . Other than that though, thanks for the help! Mar 24, 2022 at 4:46
  • @Anonymousperson I tested this out in game and it works! The command places a shulkerbox if the player has the torch named Sunny. Command: /execute if entity @p[nbt={Inventory:[{id:"minecraft:torch",Count:1b,tag:{display:{Name:'{"text":"Sunny"}'}}}]}] run setblock ~ ~2 ~ minecraft:blue_shulker_box
    – Blue Robin
    Mar 24, 2022 at 22:44
  • @ExpertCoder14 Thanks! I didn't see that. I did an edit on the command.
    – Blue Robin
    Mar 24, 2022 at 22:51
  • Thank you guys! Apr 25, 2022 at 0:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .