blob: 2fc34057c34c45392bd8eb58f97f24bce595f1ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package kubatech.api.utils;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class ItemUtils {
public static NBTTagCompound writeItemStackToNBT(ItemStack stack) {
NBTTagCompound compound = new NBTTagCompound();
stack.writeToNBT(compound);
compound.setInteger("IntCount", stack.stackSize);
return compound;
}
public static ItemStack readItemStackFromNBT(NBTTagCompound compound) {
ItemStack stack = ItemStack.loadItemStackFromNBT(compound);
if (stack == null) return null;
if (compound.hasKey("IntCount")) stack.stackSize = compound.getInteger("IntCount");
return stack;
}
}
|