mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-28 16:06:48 +01:00
Merge pull request #2499 from git-async/mc1.18/dev
- Fixed Stockpile Switch prioritizing item inventories over fluid inventories
This commit is contained in:
commit
96c5480dee
1 changed files with 25 additions and 25 deletions
|
@ -78,23 +78,24 @@ public class StockpileSwitchTileEntity extends SmartTileEntity {
|
||||||
float totalSpace = 0;
|
float totalSpace = 0;
|
||||||
|
|
||||||
observedInventory.findNewCapability();
|
observedInventory.findNewCapability();
|
||||||
if (observedInventory.hasInventory()) {
|
observedTank.findNewCapability();
|
||||||
// Item inventory
|
if (observedInventory.hasInventory() || observedTank.hasInventory()) {
|
||||||
IItemHandler inv = observedInventory.getInventory();
|
if (observedInventory.hasInventory()) {
|
||||||
for (int slot = 0; slot < inv.getSlots(); slot++) {
|
// Item inventory
|
||||||
ItemStack stackInSlot = inv.getStackInSlot(slot);
|
IItemHandler inv = observedInventory.getInventory();
|
||||||
int space = Math.min(stackInSlot.getMaxStackSize(), inv.getSlotLimit(slot));
|
for (int slot = 0; slot < inv.getSlots(); slot++) {
|
||||||
int count = stackInSlot.getCount();
|
ItemStack stackInSlot = inv.getStackInSlot(slot);
|
||||||
if (space == 0)
|
int space = Math.min(stackInSlot.getMaxStackSize(), inv.getSlotLimit(slot));
|
||||||
continue;
|
int count = stackInSlot.getCount();
|
||||||
|
if (space == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
totalSpace += 1;
|
totalSpace += 1;
|
||||||
if (filtering.test(stackInSlot))
|
if (filtering.test(stackInSlot))
|
||||||
occupied += count * (1f / space);
|
occupied += count * (1f / space);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
observedTank.findNewCapability();
|
|
||||||
if (observedTank.hasInventory()) {
|
if (observedTank.hasInventory()) {
|
||||||
// Fluid inventory
|
// Fluid inventory
|
||||||
IFluidHandler tank = observedTank.getInventory();
|
IFluidHandler tank = observedTank.getInventory();
|
||||||
|
@ -109,18 +110,17 @@ public class StockpileSwitchTileEntity extends SmartTileEntity {
|
||||||
if (filtering.test(stackInSlot))
|
if (filtering.test(stackInSlot))
|
||||||
occupied += count * (1f / space);
|
occupied += count * (1f / space);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
// No compatible inventories found
|
|
||||||
if (currentLevel == -1)
|
|
||||||
return;
|
|
||||||
level.setBlock(worldPosition, getBlockState().setValue(StockpileSwitchBlock.INDICATOR, 0), 3);
|
|
||||||
currentLevel = -1;
|
|
||||||
redstoneState = false;
|
|
||||||
sendData();
|
|
||||||
scheduleBlockTick();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// No compatible inventories found
|
||||||
|
if (currentLevel == -1)
|
||||||
|
return;
|
||||||
|
level.setBlock(worldPosition, getBlockState().setValue(StockpileSwitchBlock.INDICATOR, 0), 3);
|
||||||
|
currentLevel = -1;
|
||||||
|
redstoneState = false;
|
||||||
|
sendData();
|
||||||
|
scheduleBlockTick();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float stockLevel = occupied / totalSpace;
|
float stockLevel = occupied / totalSpace;
|
||||||
|
|
Loading…
Reference in a new issue