NBT-API

NBT-API

98.9k Downloads

itemStackFromNBT does not include size of ItemStack (Paper 1.21.1)

Dartanboy opened this issue ยท 2 comments

commented

As a very simple example:

public static String stringify(ItemStack item) {
    ReadWriteNBT nbt = NBT.itemStackToNBT(item);
    return nbt.toString();
}

public static ItemStack itemify(String itemStr) {
    ReadWriteNBT nbt = NBT.parseNBT(itemStr);
    return NBT.itemStackFromNBT(nbt);
}

Calling stringify(new ItemStack(Material.BREAD, 16)) gives the correct string - {Count:16b,id:"minecraft:bread"} however calling itemify({Count:16b,id:\"minecraft:bread\"}) results in a Bread ItemStack with only 1 item in it.

commented

That string is not correct(at least for 1.20.5+). It needs to be "count", not "Count".

commented

I see, I just had some mistakes. I apologize!