use of net.minecraft.nbt.CompoundNBT in project Overloaded by CJ-MC-Mods.
the class BigIntItemStorage method serializeNBT.
@Override
public CompoundNBT serializeNBT() {
CompoundNBT compound = new CompoundNBT();
if (storedItem.itemStack != ItemStack.EMPTY) {
CompoundNBT tag = new CompoundNBT();
storedItem.itemStack.save(tag);
compound.put("Stack", tag);
compound.putByteArray("Count", storedItem.amount.toByteArray());
}
return compound;
}
use of net.minecraft.nbt.CompoundNBT in project Overloaded by CJ-MC-Mods.
the class BigIntItemStorage method deserializeNBT.
@Override
public void deserializeNBT(CompoundNBT compound) {
ItemStack itemStack = compound.contains("Stack") ? ItemStack.of((CompoundNBT) compound.get("Stack")) : ItemStack.EMPTY;
BigInteger amount = compound.contains("Count") ? new BigInteger(compound.getByteArray("Count")) : BigInteger.ZERO;
this.storedItem = new BigIntItemStack(itemStack, amount);
}
use of net.minecraft.nbt.CompoundNBT in project Overloaded by CJ-MC-Mods.
the class TileItemInterface method getUpdatePacket.
@Nullable
@Override
public SUpdateTileEntityPacket getUpdatePacket() {
CompoundNBT tag = new CompoundNBT();
save(tag);
return new SUpdateTileEntityPacket(getBlockPos(), 1, tag);
}
use of net.minecraft.nbt.CompoundNBT in project Overloaded by CJ-MC-Mods.
the class LongItemStorage method serializeNBT.
@Override
public CompoundNBT serializeNBT() {
CompoundNBT compound = new CompoundNBT();
if (!longItemStack.getItemStack().isEmpty()) {
ItemStack stack = longItemStack.getItemStack();
stack.setCount(1);
compound.put("Item", stack.serializeNBT());
compound.putLong("Count", longItemStack.getAmount());
}
return compound;
}
use of net.minecraft.nbt.CompoundNBT in project Overloaded by CJ-MC-Mods.
the class LongItemStorage method deserializeNBT.
@Override
public void deserializeNBT(CompoundNBT compound) {
ItemStack storedItem = compound.contains("Item") ? ItemStack.of((CompoundNBT) compound.get("Item")) : null;
if (storedItem != null) {
long storedAmount = compound.contains("Count") ? compound.getLong("Count") : 0L;
longItemStack = new LongItemStack(storedItem, storedAmount);
}
}
Aggregations