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;
}
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;
}
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;
}
Aggregations