mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-26 23:13:09 +00:00
The Hopperhock now respects inventory max stack sizes.
This commit is contained in:
1 parent
97c697f9d5
commit
816baf9443
2 files changed
+12
-7
No files matched your search
@@ -47,7 +47,7 @@ public class SubTileHopperhock extends SubTileFunctional {
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(redstoneSignal > 0)
|
||||
if(redstoneSignal > 0 || supertile.getWorldObj().isRemote)
|
||||
return;
|
||||
|
||||
boolean pulledAny = false;
|
||||
@@ -97,8 +97,7 @@ public class SubTileHopperhock extends SubTileFunctional {
|
||||
|
||||
if(invToPutItemIn != null) {
|
||||
InventoryHelper.insertItemIntoInventory(invToPutItemIn, stack.copy(), sideToPutItemIn, -1);
|
||||
if(!supertile.getWorldObj().isRemote)
|
||||
item.setDead();
|
||||
item.setDead();
|
||||
pulledAny = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,12 +37,18 @@ public class InventoryHelper {
|
||||
if(targetInventory.isItemValidForSlot(slot, stack)) {
|
||||
ItemStack targetStack = targetInventory.getStackInSlot(slot);
|
||||
if(targetStack == null) {
|
||||
targetInventory.setInventorySlotContents(slot, stack.copy());
|
||||
stack.stackSize = 0;
|
||||
int space = targetInventory.getInventoryStackLimit();
|
||||
int mergeAmount = Math.min(space, stack.stackSize);
|
||||
|
||||
ItemStack copy = stack.copy();
|
||||
copy.stackSize = mergeAmount;
|
||||
targetInventory.setInventorySlotContents(slot, copy);
|
||||
stack.stackSize -= mergeAmount;
|
||||
} else if(canMerge) {
|
||||
if(targetInventory.isItemValidForSlot(slot, stack) && areMergeCandidates(stack, targetStack)) {
|
||||
int space = targetStack.getMaxStackSize() - targetStack.stackSize;
|
||||
int space = Math.min(targetInventory.getInventoryStackLimit(), targetStack.getMaxStackSize()) - targetStack.stackSize;
|
||||
int mergeAmount = Math.min(space, stack.stackSize);
|
||||
|
||||
ItemStack copy = targetStack.copy();
|
||||
copy.stackSize += mergeAmount;
|
||||
targetInventory.setInventorySlotContents(slot, copy);
|
||||
@@ -147,7 +153,7 @@ public class InventoryHelper {
|
||||
if(inventorySlot == null)
|
||||
itemSizeCounter -= Math.min(Math.min(itemSizeCounter, inventory.getInventoryStackLimit()), item.getMaxStackSize());
|
||||
else if(areMergeCandidates(item, inventorySlot)) {
|
||||
int space = inventorySlot.getMaxStackSize() - inventorySlot.stackSize;
|
||||
int space = Math.min(inventory.getInventoryStackLimit(), inventorySlot.getMaxStackSize()) - inventorySlot.stackSize;
|
||||
itemSizeCounter -= Math.min(itemSizeCounter, space);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user