Resource NBT tag editing + Reflection = Custom Items, Mobs and Blocks[UPDATED]

Discussion in 'Spigot Plugin Development' started by BananaPuncher714, Aug 30, 2017.

  1. Is it possible to make a method to return every single nbt tag or nah?
  2. No, but you could try to do it yourself. If you really want it I could try.:)
  3. Ah that's why I was asking, I'm pretty bad at this doing this stuff, I could give it a try I just have no idea where to start xD, I'd like if you could try, it's cool if u don't wanna
  4. I'll do this later today when I have time
  5. Then i'll recommend to do 2 versions - `lite` , with only get and set, and full - with every other feachures included :3
  6. @Azim @TheCrystalStar I have updated it so now it returns nested hashmaps with all the tags inside. You can iterate through it like this:
    Code (Java):
    private void printNestedMap( Object base, Map< Object, Object > map ) {
        for ( Iterator< Object > it = map.keySet().iterator(); it.hasNext(); ) {
            Object base2 =;
            Object mm = map.get( base2 );
            if ( mm instanceof Map ) {
                printNestedMap( base + "." + base2, ( Map< Object, Object > ) mm );
            } else {
                System.out.println( base + "." + base2 + "." + mm );
    Just don't provide any extra arguments when using getItemTag(), only the itemstack.
    • Useful Useful x 1
  7. I have now added support for Tile Entities!! Also, when getting NBT values, note that they may not necessarily exist when you try to get them!
  8. I would just like to point out to everyone else that as far as I know, NBT data will be removed in 1.13.
  9. Well, rip this resource I guess :p
  10. Nice! Good work, NBT is truly amazing :p
  11. That's basically wrong.
    1. Item ID's gets removed. Conversion to String item names like "minecraft:stone".
    2. Item/Block Variant get their own type.
    3. NBT Data e.g. color of leather armor is kept.
    • Informative Informative x 1
    • Useful Useful x 1
  12. Sorry my mistake, I thought that information would've been stored somewhere else. Thanks for clarifying that for me.
  13. @EventHandler
    public void colocar(BlockPlaceEvent e) {
    if (e.getItemInHand().getType().equals(Material.MOSSY_COBBLESTONE)) {
    NBTEditor.setBlockTag(e.getBlockPlaced(), true, "MoneyPrinter");

    public void clicar(PlayerInteractEvent e) {
    if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
    Object money = NBTEditor.getBlockTag(e.getClickedBlock(), "MoneyPrinter");
    Bukkit.broadcastMessage("Este bloco é moneyprinter ?: " + money);

    This is returning always null. anybody knows why ?
  14. You aren't able to assign tile entities or normal entities tags that they aren't supposed to have. It's better to use its location as a key in a map or set. Also, NBT Tags don't support boolean values, so you'll have to use byte values or a string. :)

Share This Page