NBT-API

NBT-API

98.9k Downloads

[Suggestion] Pretty NBT

ShaneBeee opened this issue ยท 5 comments

commented

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

commented

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

commented

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.

commented

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.

commented

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

commented

I was looking for it. Would be a great feature