0

hopefully the last question for this map.

I'm trying to have a command check if the player is holding a compass with an arbitrary tag, using this command to give them the compass:

/give @p minecraft:compass{display:{Name:"{\"text\":\"Dungeon Compass\"}",Lore:["{\"text\":\"A compass. Holding this in your\"}","{\"text\":\"hand, you can see where the\"}","{\"text\":\"Triforce piece is!\"}","{\"text\":\"Legendary compasses were once\",\"color\":\"gold\"}","{\"text\":\"used to navigate the most \",\"color\":\"gold\"}","{\"text\":\"treacherous of dungeons. Now,\",\"color\":\"gold\"}","{\"text\":\"few of such items remain, lest\",\"color\":\"gold\"}","{\"text\":\"Ganon find one.\",\"color\":\"gold\"}"]},Tags:["navi:1"]} 1

and expanded:

/give @p minecraft:compass{  
   display:{  
      Name:"{\"text\":\"Dungeon Compass\"}",
      Lore:[  
         "{\"text\":\"A compass. Holding this in your\"}",
         "{\"text\":\"hand, you can see where the\"}",
         "{\"text\":\"Triforce piece is!\"}",
         "{\"text\":\"Legendary compasses were once\",\"color\":\"gold\"}",
         "{\"text\":\"used to navigate the most \",\"color\":\"gold\"}",
         "{\"text\":\"treacherous of dungeons. Now,\",\"color\":\"gold\"}",
         "{\"text\":\"few of such items remain, lest\",\"color\":\"gold\"}",
         "{\"text\":\"Ganon find one.\",\"color\":\"gold\"}"
      ]
   },
   Tags:[
      "navi:1"
   ]
} 1

So what the idea is is that when a player is holding this item, it'll set their scoreboard at 1:

scoreboard players set @a navi1 0
scoreboard players set @a[nbt={SelectedItem:{tag:{Tags:"navi:1"}}}] navi1 1

Issue I'm running into is that the item simply is not getting detected. I'm guessing I've failed in my syntax around the detection of what tag is attached to it, but I've yet to be able to find any information about executing at a player holding an item with an arbitrary tag.

Thanks guys!

  • 1
    Using arbitrary tags always worries me because I never can tell if they should work or not. Do you think there is a way of doing this without using arbitrary tags? – MBraedley Jun 11 at 13:49
  • I have considered using custom names, although I'd prefer the difference between them to be as discrete as possible. Is it possible to execute based on the colour of the name? – Dalek_Thal Jun 11 at 14:21
  • Your tag name is "navi:1"? I'm not sure if colons work in tag names, at the very least it produces confusing commands. I recommend renaming the tag. – Fabian Röling Jun 11 at 14:50
  • Admittedly that was in response to command blocks telling me that my syntax was wrong and I needed a colon. Did I miss something in the targeting command? – Dalek_Thal Jun 11 at 14:52
3

You forgot the square brackets:

scoreboard players set @a[nbt={SelectedItem:{tag:{Tags:["navi:1"]}}}] navi1 1

That said, this is more complicated than it needs to be. The "Tags" tag for entities is a convenience, it gets converted to actually tags as soon as an entity is summoned. But you're not actually summoning an entity here, you're just changing an inventory slot. What actually happens is that you're using the feature of giving items arbitrary tags. You could just as well do /give @s stone{a:b} and test for it with SelectedItem:{tags:{a:"b"}}. You can also write lists and everything else into it, but since these have no meaning for the game, I recommend not doing that (in 99.999% of cases).

I also recommend not using colons in tag names or values if you can avoid it easily. It just causes confusion. There might also be cases where it breaks commands, but I don't know any.

  • 1
    Happens to the best of us :) – Quijibo Jun 11 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.