Search in sources :

Example 16 with CompoundNBT

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;
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT)

Example 17 with CompoundNBT

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);
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) BigIntItemStack(com.cjm721.overloaded.storage.stacks.bigint.BigIntItemStack) BigInteger(java.math.BigInteger) LongItemStack(com.cjm721.overloaded.storage.stacks.intint.LongItemStack) ItemStack(net.minecraft.item.ItemStack) BigIntItemStack(com.cjm721.overloaded.storage.stacks.bigint.BigIntItemStack)

Example 18 with CompoundNBT

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);
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) SUpdateTileEntityPacket(net.minecraft.network.play.server.SUpdateTileEntityPacket) Nullable(javax.annotation.Nullable)

Example 19 with CompoundNBT

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;
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) LongItemStack(com.cjm721.overloaded.storage.stacks.intint.LongItemStack) ItemStack(net.minecraft.item.ItemStack)

Example 20 with CompoundNBT

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);
    }
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) LongItemStack(com.cjm721.overloaded.storage.stacks.intint.LongItemStack) ItemStack(net.minecraft.item.ItemStack) LongItemStack(com.cjm721.overloaded.storage.stacks.intint.LongItemStack)

Aggregations

CompoundNBT (net.minecraft.nbt.CompoundNBT)127 ItemStack (net.minecraft.item.ItemStack)33 ListNBT (net.minecraft.nbt.ListNBT)19 Nonnull (javax.annotation.Nonnull)12 PlayerEntity (net.minecraft.entity.player.PlayerEntity)10 BlockPos (net.minecraft.util.math.BlockPos)10 ResourceLocation (net.minecraft.util.ResourceLocation)9 BlockState (net.minecraft.block.BlockState)8 TileEntity (net.minecraft.tileentity.TileEntity)7 StringTextComponent (net.minecraft.util.text.StringTextComponent)7 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)6 DimensionType (net.minecraft.world.dimension.DimensionType)6 TileBPMultipart (com.bluepowermod.tile.TileBPMultipart)5 Block (net.minecraft.block.Block)5 ArrayList (java.util.ArrayList)4 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)4 SUpdateTileEntityPacket (net.minecraft.network.play.server.SUpdateTileEntityPacket)4 LongItemStack (com.cjm721.overloaded.storage.stacks.intint.LongItemStack)3 Nullable (javax.annotation.Nullable)3 IItemProvider (net.minecraft.util.IItemProvider)3