Search in sources :

Example 6 with LongItemStack

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

the class LongItemStorage method insertItem.

@Override
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
    LongItemStack result = give(new LongItemStack(stack, stack.getCount()), !simulate);
    if (result.getAmount() == 0) {
        return ItemStack.EMPTY;
    }
    ItemStack toReturn = stack.copy();
    toReturn.setCount(result.getAmount().intValue());
    return toReturn;
}
Also used : LongItemStack(com.cjm721.overloaded.storage.stacks.intint.LongItemStack) ItemStack(net.minecraft.item.ItemStack) LongItemStack(com.cjm721.overloaded.storage.stacks.intint.LongItemStack) Nonnull(javax.annotation.Nonnull)

Example 7 with LongItemStack

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

the class LongItemStorage method extractItem.

@Override
@Nonnull
public ItemStack extractItem(int slot, int amount, boolean simulate) {
    LongItemStack result = take(new LongItemStack(ItemStack.EMPTY, amount), !simulate);
    if (result.getAmount() == 0L) {
        return ItemStack.EMPTY;
    }
    ItemStack toReturn = result.getItemStack().copy();
    toReturn.setCount(result.getAmount().intValue());
    return toReturn;
}
Also used : LongItemStack(com.cjm721.overloaded.storage.stacks.intint.LongItemStack) ItemStack(net.minecraft.item.ItemStack) LongItemStack(com.cjm721.overloaded.storage.stacks.intint.LongItemStack) Nonnull(javax.annotation.Nonnull)

Example 8 with LongItemStack

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

the class LongItemStorage method give.

@Nonnull
@Override
public LongItemStack give(@Nonnull LongItemStack stack, boolean doAction) {
    if (longItemStack.getItemStack().isEmpty()) {
        if (doAction) {
            longItemStack = new LongItemStack(stack.getItemStack(), stack.getAmount());
            dataUpdate.dataUpdated();
        }
        return LongItemStack.EMPTY_STACK;
    }
    if (ItemHandlerHelper.canItemStacksStack(longItemStack.getItemStack(), stack.getItemStack())) {
        NumberUtil.AddReturn<Long> result = addToMax(longItemStack.getAmount(), stack.getAmount());
        if (doAction) {
            longItemStack.setAmount(result.result);
            dataUpdate.dataUpdated();
        }
        return new LongItemStack(stack.getItemStack(), result.overflow);
    }
    return stack;
}
Also used : NumberUtil(com.cjm721.overloaded.util.NumberUtil) LongItemStack(com.cjm721.overloaded.storage.stacks.intint.LongItemStack) Nonnull(javax.annotation.Nonnull)

Aggregations

LongItemStack (com.cjm721.overloaded.storage.stacks.intint.LongItemStack)6 Nonnull (javax.annotation.Nonnull)6 ItemStack (net.minecraft.item.ItemStack)4 LongItemStack (com.cjm721.overloaded.storage.LongItemStack)1 BigIntItemStack (com.cjm721.overloaded.storage.stacks.bigint.BigIntItemStack)1 NumberUtil (com.cjm721.overloaded.util.NumberUtil)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1