Minecraft – Add multiple NBT tag Tags

minecraft-commandsminecraft-java-edition

Context:
Ok, so I am making some custom enchantment stuffs and I want to be able to change the NBT data of the item, the way I am doing it is just making the players put the items into a chest then /fill destroy and killing the chest item, since the items are now entities I can use /entitydata to edit the items NBT datas, I've done this pretty well to an extent. I've looked around to no avail.

Problem:
entitydata @e[type=Item,c=1] {Item:{tag:{Tags:[hi]}}}
works, it gives the player a stone with the tag "hi"
entitydata @e[type=Item,c=1] {Item:{tag:{Tags:[hi,hello,test]}}}

The 2nd problem is, even if I try to use lore and just use the section sign or something to make an "invisible string" it just replaces the lore with the new one, is there any thing that I can use to "add" NBT data to something like mentioned above?

Also, if I were to run a /scoreboard players add {data}
how would I make the data be separate, so I could run executes on it, and players holding those items, say if a player was holding something with the tags: [kill,fly] when I execute on it, I can make the player execute the kill function and the fly function

Best Answer

No, you can not currently add NBT data to data which already exists. You have to overwrite the existing data in order to modify it. I am referring to lore with this.

In the case of scoreboard tags, you can add and remove specific tags without modifying the rest, but not with the entitydata command.

You have to use the scoreboard tag commands for this:

scoreboard players tag <entity> add <tagName> [dataTag]
scoreboard players tag <entity> remove <tagName> [dataTag]