Mod sometimes copies NBT incorrectly
Moonyol opened this issue ยท 1 comments
Describe the bug
If you attempt to copy an item with the character ' or " in its NBT, for example egg{display:{Name:'{"text":"a'a"}'}} and attempt to copy it, it will alter the NBT by changing it to egg{"display":{"Name":"{"text":"a'a"}"}} which changes the quotations around the Name tag however if you look at the NBT while it is still inside your inventory it will display the correct type of quotations
To Reproduce
Steps to reproduce the behavior:
- Do /give @p egg{display:{Name:'{"text":"a"a"}'}}
- Copy the NBT
- Attempt to give yourself the item with /give
- It doesn't work
Expected behavior
It should've copied the NBT from the item without changing it which would make the give command work properly
Pastebin links
Don't paste the whole lists here, use pastebin
Environment (please complete the following information):
- Mod Version: 1.7.1
- MC Version: 1.19.4
- Fabric Version: 0.14.19
- Fabric API version: 0.80.0
- System: Windows 10
- Installation type: Singleplayer and Multiplayer
Additional context
Add any other context about the problem here, like other mods that you think might be involved in the problem.
When you use the give command and specify an nbt tag, the tag is not saved as a string exactly as you type it.
The tag is saved as a tree of values. In your case it is saving the 'Name' property as a string, which is a child of the 'display' property.
The itemstack itself has no data on what kind of quotes you used, they get lost in the abstraction.
I'm using double quotes when rebuilding the string by default, since this is not meant to be an advanced instrument but only something I use to debug my other mods.
If it doesn't break your logic, you can invert the type of all quotation marks in your command to work around the issue