Search in sources :

Example 1 with BigIntItemStack

use of com.cjm721.overloaded.storage.stacks.bigint.BigIntItemStack 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 2 with BigIntItemStack

use of com.cjm721.overloaded.storage.stacks.bigint.BigIntItemStack in project Overloaded by CJ-MC-Mods.

the class BigIntItemStorage method give.

@Nonnull
@Override
public LongItemStack give(@Nonnull LongItemStack stack, boolean doAction) {
    if (storedItem.itemStack.isEmpty()) {
        if (doAction) {
            storedItem = new BigIntItemStack(stack.getItemStack(), BigInteger.valueOf(stack.getAmount()));
            dataUpdate.dataUpdated();
        }
        return LongItemStack.EMPTY_STACK;
    }
    if (ItemHandlerHelper.canItemStacksStack(storedItem.itemStack, stack.getItemStack())) {
        if (doAction) {
            storedItem.amount = storedItem.amount.add(BigInteger.valueOf(stack.getAmount()));
            dataUpdate.dataUpdated();
        }
        return LongItemStack.EMPTY_STACK;
    }
    return stack;
}
Also used : BigIntItemStack(com.cjm721.overloaded.storage.stacks.bigint.BigIntItemStack) Nonnull(javax.annotation.Nonnull)

Aggregations

BigIntItemStack (com.cjm721.overloaded.storage.stacks.bigint.BigIntItemStack)2 LongItemStack (com.cjm721.overloaded.storage.stacks.intint.LongItemStack)1 BigInteger (java.math.BigInteger)1 Nonnull (javax.annotation.Nonnull)1 ItemStack (net.minecraft.item.ItemStack)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1