0

Very simple short and straightforward. I found that if I give myself firework_rockets with a custom tag called 'test', the item has an nbt={Tags:['test']}. The command I use is /give @s firework_rocket{Tags:['test']} 64

However once the firework is shot via a crossbow, I tried to retrieve its data and to my surprise, found out that the Tags:['test'] is not stored directly in the entity, but more discretely in an nbt called tag=. For example: entity firework_rocket has the following data --- {OnGround:0b,Air:300s,blah blah blah, tag: {Tags:["test"]},Count:64b}

As seen from above, this Tags:["test"] tag in being stored in an nbt tag called tag. If I want to detect a specific nbt tag such as the Air tag, I could do so simply with execute at @e[nbt={Air:300s}] run summon tnt

But what I want to do here is to detect the Tags:["test"] tag. /execute at @e[nbt={tag:{Tags:["test"]}}] simply wont work.

SuperStormer
  • 4,997
  • 5
  • 25
  • 35
hfanatic
  • 149
  • 1
  • 4

1 Answers1

0

I don't know if you want a command to run when you select the firework or when it turns into an entity, but here are both commands. For both instances:

Entity : /execute as @e[nbt={tag:{Tags:["test"]}}] at @s run <command>

Item : /execute as @e[nbt={SelectedItem:{tag:{Tags:["test"]}}}] at @s run <command>

LolXDDev
  • 63
  • 1
  • 5
  • Firstly, please take the time to do a good answer instead of editing it lot of time. Then, don't always use **bold**, but keep it for **keywords**. – Elikill58 Sep 24 '21 at 08:47
  • Unfortunately that doesn't work. I am using visual studio code with Minecraft datapack addon. It shows that the code had no flaw, but it just won't run as planned. The first command seems to be right but it doesnt run – hfanatic Oct 08 '21 at 15:39
  • It should be `@e[nbt={Tags:["test"]}]...` – kirbycope May 29 '22 at 19:49