tr7zw / Item-NBT-API

Add custom NBT tags to Items/Tiles/Entities without NMS!
https://www.spigotmc.org/resources/item-entity-tile-nbt-api.7939/
MIT License
557 stars 76 forks source link

[Suggestion] Pretty NBT #142

Open ShaneBeee opened 2 years ago

ShaneBeee commented 2 years ago

I wanted to suggest the addition of pretty NBT printing. This is basically what Minecraft uses when you run the /data command, and its prints the colourful NBT strings

Here is an example showing printing an NBT compound, pretty printing a compound, and pretty printing a compound with a split (split creates new lines, with a string option for how it spaces):

If it helps at all, I will include my class I use in my plugin for this: https://github.com/ShaneBeee/SkBee/blob/master/src/main/java/com/shanebeestudios/skbee/api/reflection/ChatReflection.java (pardon my messy code) Just a heads up also, Minecraft changed the way it worked in 1.17 with a new "tag visitor" system, hence the 2 sets of reflection for 1.16 and 1.17 Hope this helps

tr7zw commented 2 years ago

That is a good idea. Will add this in the next update.

tr7zw commented 2 years ago

Uhhhhhh I need more time to do this one, especially in regards to older versions(down to 1.7.10). So it won't be in the next release.

ShaneBeee commented 2 years ago

That's totally fine. Just a heads up, MC introduced this in MC 1.13, so I would assume you could skip it for lower versions, or just print a string.

tr7zw commented 2 years ago

The "simplest" way probably is to implement my own formatter. Then it bypasses the issue of older versions in general.

SuSeu1414 commented 1 year ago

I was looking for it. Would be a great feature