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?

8
  • Does it work if you specify Item.tag.display.Lore[1] as the path? Commented Oct 8, 2018 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
    Commented Oct 8, 2018 at 17:37
  • You mean you don't know how many lore lines there already are? Commented Oct 9, 2018 at 6:08
  • Yup. I don't know how many lines :|
    – nift4
    Commented Oct 9, 2018 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. Commented Oct 9, 2018 at 12:25

2 Answers 2

2

1.14 introduces this feature using the "append" mode of /data modify:

/data modify entity @e[type=item,limit=1] Item.tag.display.Lore append value "{\"text\":\"second line\"}"
-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

1
  • 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
    Commented Oct 8, 2018 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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