mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-19 11:59:17 +00:00
Merge pull request #2132 from HenryLoenwind/farmerStacksize
Fix: Stack size limits on Farming Station
This commit is contained in:
commit
f4ea2aecb7
3 files changed
+38
-10
No files matched your search
@@ -367,7 +367,7 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
|
||||
|
||||
boolean hasSpace = false;
|
||||
for (int slot = slotDefinition.minInputSlot; slot <= slotDefinition.maxInputSlot && !hasSpace; slot++) {
|
||||
hasSpace = inventory[slot] == null ? true : inventory[slot].stackSize < inventory[slot].getMaxStackSize();
|
||||
hasSpace = inventory[slot] == null ? true : inventory[slot].stackSize < Math.min(inventory[slot].getMaxStackSize(), getInventoryStackLimit(slot));
|
||||
}
|
||||
if(!hasSpace) {
|
||||
return false;
|
||||
@@ -569,6 +569,10 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
|
||||
return slotDefinition.getNumSlots();
|
||||
}
|
||||
|
||||
public int getInventoryStackLimit(int slot) {
|
||||
return getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
@@ -608,8 +612,8 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
|
||||
inventory[slot] = contents.copy();
|
||||
}
|
||||
|
||||
if(contents != null && contents.stackSize > getInventoryStackLimit()) {
|
||||
contents.stackSize = getInventoryStackLimit();
|
||||
if(contents != null && contents.stackSize > getInventoryStackLimit(slot)) {
|
||||
contents.stackSize = getInventoryStackLimit(slot);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,11 +62,7 @@ public class FarmStationContainer extends AbstractMachineContainer {
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
if(slot > 2 && slot < 7) {
|
||||
int tier = ((TileFarmStation)tileEntity).getCapacitorType().ordinal();
|
||||
return (int) (16 * Math.pow(2, tier));
|
||||
}
|
||||
return 64;
|
||||
return ((TileFarmStation)tileEntity).getInventoryStackLimit(slot);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -614,12 +614,19 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
for (int j = 0; j < slots.length && inserted < stack.stackSize; j++) {
|
||||
int i = slots[j];
|
||||
ItemStack curStack = inventory[i];
|
||||
if(isItemValidForSlot(i, stack) && (curStack == null || curStack.stackSize < 16)) {
|
||||
int inventoryStackLimit = getInventoryStackLimit(i);
|
||||
if(isItemValidForSlot(i, stack) && (curStack == null || curStack.stackSize < inventoryStackLimit)) {
|
||||
if(curStack == null) {
|
||||
if (stack.stackSize < inventoryStackLimit) {
|
||||
inventory[i] = stack.copy();
|
||||
inserted = stack.stackSize;
|
||||
} else {
|
||||
inventory[i] = stack.copy();
|
||||
inserted = inventoryStackLimit;
|
||||
inventory[i].stackSize = inserted;
|
||||
}
|
||||
} else if(curStack.isItemEqual(stack)) {
|
||||
inserted = Math.min(16 - curStack.stackSize, stack.stackSize);
|
||||
inserted = Math.min(inventoryStackLimit - curStack.stackSize, stack.stackSize);
|
||||
inventory[i].stackSize += inserted;
|
||||
}
|
||||
}
|
||||
@@ -757,4 +764,25 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
nbtRoot.setInteger("slotLayoutVersion", 3);
|
||||
}
|
||||
|
||||
public int getInventoryStackLimit(int slot) {
|
||||
if (slot >= minSupSlot && slot <= maxSupSlot) {
|
||||
switch (getCapacitorType()) {
|
||||
case BASIC_CAPACITOR:
|
||||
return 16;
|
||||
case ACTIVATED_CAPACITOR:
|
||||
return 32;
|
||||
case ENDER_CAPACITOR:
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
// We return the (lowered) input slot limit here, so others who insert into us
|
||||
// will behave nicely.
|
||||
return getInventoryStackLimit(minSupSlot);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user