NBT-API

NBT-API

98.9k Downloads

NBT from ItemStack results to air.

Shin1gamiX opened this issue ยท 6 comments

commented

Any itemstack I try to convert into an NBT instance, results into AIR in 1.17.1.
In any previous version that works fine.

ItemStack stack = new ItemStack(Material.DIRT);
// The stack above will result DIRT as it's type.
final NBTItem nbti = new NBTItem(stack, true);
stack = NBTItem.convertNBTtoItem(nbti);
// the stack above will return AIR as it's type.

commented

You can join the discord, linked on places like the readme.md. But yea as I said, the convertNBTtoItem will basically never work when directly inputting an NBTItem(except if you happen to have an id tag in the nbt, but then it will lose item amounts and all other nbt).

commented

Using any method will result in the resulted itemstack being AIR, doesn't matter which method of the two I'll use. I can't reason why that is happening, and why it was not happening in previous versions of the plugin. Is there a way for me to share the jar file to you (of the working version) and the broken one? Perhaps you can check through the code to see where I messed up? Although I haven't changed anything in regards to the API. Nor have I changed any huge chunk of code that would result in such behaviours.

commented

So NBTItem.convertNBTtoItem is not a valid method for converting NBTItems to itemstacks?
I've been using that method since the beggining and was working fine. In fact, I haven't changed the code and it stopped working after sometime. My plugin's working version is 1.8.4 and any version after that stopped working. The code remains unchanged and I am struggling to find what's causing it.

This issue also occurs with #getItem() as well.

I'm struggling to figure out what's causing this. Litterly converting a simple ItemStack with no data to an NBTItem and then back to an ItemStack will result in it becoming AIR.

commented

NBTItem.convertNBTtoItem converts {id:"Stone", count:1} to an ItemStack. But NBTItem is by default just {} since there is no data on the item. Or an example with an item that has nbt:

    {
        id: "wooden_sword",
        Count: 1,
        tag: {
            display: {
                Name: "test"
            }
        }
    }

What NBTItem.convertNBTtoItem needs is this entire thing, what you give it is the stuff inside the "tag" tag. So: {display:{Name:"test"}}

commented

This 100% also not worked in other versions. NBTItem can not be converted to an ItemStack since it represents the data ON the stack, not the stack itself. You are looking for nbti.getItem().

commented

This issue started happening after I compiled the plugin in java 16, could that be an issue?

However, in minecraft version 1.8.8 with java(8/16), it seems to be working just fine.