Add getSlotLimit(slot) to IItemHandler (#3445)

This commit is contained in:
Vincent Lee authored and LexManos committed 2016-11-28 16:03:47 -08:00
1 parent b048c1a4b5
commit c17b40790b
9 files changed
+99 -5

No files matched your search

@@ -123,4 +123,13 @@ public class CombinedInvWrapper implements IItemHandlerModifiable
slot = getSlotFromIndex(slot, index);
return handler.extractItem(slot, amount, simulate);
}
@Override
public int getSlotLimit(int slot)
{
int index = getIndexForSlot(slot);
IItemHandlerModifiable handler = getHandlerFromIndex(index);
int localSlot = getSlotFromIndex(slot, index);
return handler.getSlotLimit(localSlot);
}
}
@@ -61,4 +61,10 @@ public class EmptyHandler implements IItemHandlerModifiable
{
// nothing to do here
}
@Override
public int getSlotLimit(int slot)
{
return 0;
}
}
@@ -86,7 +86,7 @@ public class InvWrapper implements IItemHandlerModifiable
if (!ItemHandlerHelper.canItemStacksStack(stack, stackInSlot))
return stack;
m = Math.min(stack.getMaxStackSize(), getInv().getInventoryStackLimit()) - stackInSlot.func_190916_E();
m = Math.min(stack.getMaxStackSize(), getSlotLimit(slot)) - stackInSlot.func_190916_E();
if (stack.func_190916_E() <= m)
{
@@ -121,7 +121,7 @@ public class InvWrapper implements IItemHandlerModifiable
}
else
{
m = Math.min(stack.getMaxStackSize(), getInv().getInventoryStackLimit());
m = Math.min(stack.getMaxStackSize(), getSlotLimit(slot));
if (m < stack.func_190916_E())
{
// copy the stack to not modify the original one
@@ -192,6 +192,12 @@ public class InvWrapper implements IItemHandlerModifiable
getInv().setInventorySlotContents(slot, stack);
}
@Override
public int getSlotLimit(int slot)
{
return getInv().getInventoryStackLimit();
}
public IInventory getInv()
{
return inv;
@@ -94,6 +94,17 @@ public class RangedWrapper implements IItemHandlerModifiable {
}
}
@Override
public int getSlotLimit(int slot)
{
if (checkSlot(slot))
{
return compose.getSlotLimit(slot + minSlot);
}
return 0;
}
private boolean checkSlot(int localSlot)
{
return localSlot + minSlot < maxSlot;
@@ -104,7 +104,7 @@ public class SidedInvWrapper implements IItemHandlerModifiable
if (!ItemHandlerHelper.canItemStacksStack(stack, stackInSlot))
return stack;
m = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit()) - stackInSlot.func_190916_E();
m = Math.min(stack.getMaxStackSize(), getSlotLimit(slot)) - stackInSlot.func_190916_E();
if (stack.func_190916_E() <= m)
{
@@ -137,7 +137,7 @@ public class SidedInvWrapper implements IItemHandlerModifiable
}
else
{
m = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit());
m = Math.min(stack.getMaxStackSize(), getSlotLimit(slot));
if (m < stack.func_190916_E())
{
// copy the stack to not modify the original one
@@ -211,4 +211,10 @@ public class SidedInvWrapper implements IItemHandlerModifiable
return inv.decrStackSize(slot1, m);
}
}
@Override
public int getSlotLimit(int slot)
{
return inv.getInventoryStackLimit();
}
}