2

I'm having (for example) a entity (Drop) with this NBT:

{Item:{tag:{display:{Lore:["test1"]}},id:"minecraft:bread"}}

I'm trying to add a new lore:

/data merge entity @e[type=item,tag=myDrop] {Item:{tag:{display:{Lore:["test2"]}}}}

But when I execute this and collect my drop there is ONLY test2 as lore but i need test1 and test2. Please help! Thanks.

EDIT: I don't know the content and/or the count of test1.

EDIT2: So simply a array.append() but how in minecraft?

  • Does it work if you specify Item.tag.display.Lore[1] as the path? – Fabian Röling Oct 8 '18 at 16:19
  • I have a lot of data and this is a part but I haven't tried path because i don't know how much test1 is there. – nift4 Oct 8 '18 at 17:37
  • You mean you don't know how many lore lines there already are? – Fabian Röling Oct 9 '18 at 6:08
  • Yup. I don't know how many lines :| – nift4 Oct 9 '18 at 12:15
  • I don't know if there is a way to get the number of items in an NBT array. Also, I just noticed that /data merge doesn't have a path argument. I don't think it's possible to do what you want. – Fabian Röling Oct 9 '18 at 12:25
0

1.14 introduces this feature using /data. Thanks to @Fabian Röling

-1

Try

/data merge entity @e[type=item,limit=1] {Item:{tag:{display:{Lore:["test2","test1"]}}}}

You're still replacing the original test1, but you can just replace it with test1, or you could change it.

Hope this helps! :D

  • Hi! Thanks for the answer, but I have an lore I don't know and only want to add mine.(I'm making a custom enchantment in a datapack that works but i cant add the enchantment desc as a lore). See question edit. – nift4 Oct 8 '18 at 17:33

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.