mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-20 12:19:46 +00:00
Allow Hopperhock to split stacks
Change hopperhock logic so that it will split a stack on the ground if the adjacent inventories only have space for some of it. Fixes #1683.
This commit is contained in:
1 parent
1e54c88aad
commit
81a452d905
1 file changed
+9
-5
@@ -73,6 +73,7 @@ public class SubTileHopperhock extends SubTileFunctional {
|
||||
IInventory invToPutItemIn = null;
|
||||
ForgeDirection sideToPutItemIn = ForgeDirection.UNKNOWN;
|
||||
boolean priorityInv = false;
|
||||
int amountToPutIn = 0;
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
int x_ = x + dir.offsetX;
|
||||
@@ -83,8 +84,8 @@ public class SubTileHopperhock extends SubTileFunctional {
|
||||
if(inv != null) {
|
||||
List<ItemStack> filter = getFilterForInventory(inv, x_, y_, z_, true);
|
||||
boolean canAccept = canAcceptItem(stack, filter, filterType);
|
||||
int stackSize = InventoryHelper.testInventoryInsertion(inv, stack, dir);
|
||||
canAccept &= stackSize == stack.stackSize;
|
||||
int availablePut = InventoryHelper.testInventoryInsertion(inv, stack, dir);
|
||||
canAccept &= availablePut > 0;
|
||||
|
||||
if(canAccept) {
|
||||
boolean priority = !filter.isEmpty();
|
||||
@@ -96,19 +97,22 @@ public class SubTileHopperhock extends SubTileFunctional {
|
||||
invToPutItemIn = inv;
|
||||
priorityInv = priority;
|
||||
sideToPutItemIn = dir.getOpposite();
|
||||
amountToPutIn = availablePut;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(invToPutItemIn != null) {
|
||||
boolean remote = supertile.getWorldObj().isRemote;
|
||||
boolean remote = supertile.getWorldObj().isRemote;
|
||||
if(!item.isDead && remote)
|
||||
SubTileSpectranthemum.spawnExplosionParticles(item, 1);
|
||||
else {
|
||||
InventoryHelper.insertItemIntoInventory(invToPutItemIn, stack.copy(), sideToPutItemIn, -1);
|
||||
InventoryHelper.insertItemIntoInventory(invToPutItemIn, stack.splitStack(amountToPutIn), sideToPutItemIn, -1);
|
||||
invToPutItemIn.markDirty();
|
||||
item.setDead();
|
||||
item.setEntityItemStack(stack.splitStack(stack.stackSize - amountToPutIn));
|
||||
if(item.getEntityItem().stackSize == 0)
|
||||
item.setDead();
|
||||
pulledAny = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user