allow interface itemstack handler to accept over sized stacks

This commit is contained in:
PrototypeTrousers
2022-10-12 17:40:25 -03:00
parent 2e9a5dc8ea
commit 4bac5f43db
9 changed files with 124 additions and 16 deletions
@@ -48,6 +48,7 @@ import appeng.helpers.InventoryAction;
import appeng.me.helpers.PlayerSource;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.inv.AdaptorItemHandler;
import appeng.util.inv.WrapperCursorItemHandler;
import appeng.util.item.AEItemStack;
@@ -387,10 +388,7 @@ public abstract class AEBaseContainer extends Container {
if (Platform.itemComparisons().isSameItem(tis, t)) // t.isItemEqual(tis))
{
int maxSize = t.getMaxStackSize();
if (maxSize > d.getSlotStackLimit()) {
maxSize = d.getSlotStackLimit();
}
int maxSize = d.getSlotStackLimit();
int placeAble = maxSize - t.getCount();
@@ -406,9 +404,7 @@ public abstract class AEBaseContainer extends Container {
if (tis.getCount() <= 0) {
clickSlot.putStack(ItemStack.EMPTY);
d.onSlotChanged();
// if ( hasMETiles ) updateClient();
this.updateSlot(clickSlot);
this.updateSlot(d);
return ItemStack.EMPTY;
@@ -589,6 +585,20 @@ public abstract class AEBaseContainer extends Container {
s.putStack(is);
}
break;
case HALVE:
if (s.getStack().getCount() > 1) {
ItemStack halved = s.getStack().copy();
halved.setCount(s.getStack().getCount() / 2);
s.putStack(halved);
}
break;
case DOUBLE:
ItemStack doubled = s.getStack().copy();
if (s.getStack().getCount() * 2 > 0) {
doubled.setCount(Math.min(s.getSlotStackLimit(), s.getStack().getCount() * 2));
s.putStack(doubled);
}
break;
case CREATIVE_DUPLICATE:
case MOVE_REGION:
case SHIFT_CLICK: