NBT-API

NBT-API

98.9k Downloads

Issue at converting json itemStack to ItemStack.

OOP-778 opened this issue · 3 comments

commented

Hello, I have an issue with converting json string to ItemStack.
Here's my prototype code:

        NBTItem nbtItem = new NBTItem(event.getItem());
        String nbtItemString = nbtItem.asNBTString();
        System.out.println(nbtItemString);

        ItemStack item = NBTItem.convertNBTtoItem(new NBTContainer(nbtItemString));
        System.out.println(item);

And the output is:
{lvl:"1",display:{Lore:["This hopper teleports specified monster type","To it's location & freezes them","* Current mob: Pig"],Name:"[MobGrind] Hopper"},isGlobal:"false",isAuto:"false",ent:"PIG",type:"Grind",name0:"grindHopper"}

ItemStack{AIR x 0}

Am I doing smth wrong?

commented

Yea, you have to use NBTItem.convertItemtoNBT(item).asNBTString().
If you just use an NBTItem and call asNBTString() you just get the data on the Item, but not the Item itself.

commented

@misterzet Any other problems or can I close the issue?

commented