use of net.minecraft.inventory.ISidedInventory in project BluePower by Qmunity.
the class TileRegulator method isSatisfied.
/**
* Returns true if the supplying inventory has the items stated in the output filter.
*
* @return
*/
private boolean isSatisfied() {
IInventory inv = IOHelper.getInventoryForTE(getTileCache(getOutputDirection()));
if (inv != null) {
int[] accessibleSlots;
if (inv instanceof ISidedInventory) {
accessibleSlots = ((ISidedInventory) inv).getAccessibleSlotsFromSide(getFacingDirection().ordinal());
} else {
accessibleSlots = new int[inv.getSizeInventory()];
for (int i = 0; i < accessibleSlots.length; i++) accessibleSlots[i] = i;
}
boolean everythingNull = true;
for (int i = 18; i < 27; i++) {
if (inventory[i] != null) {
everythingNull = false;
int outputFilterItems = getItemsInSection(inventory[i], EnumSection.OUTPUT_FILTER);
int supplyingInvCount = 0;
for (int slot : accessibleSlots) {
ItemStack stackInSlot = inv.getStackInSlot(slot);
if (stackInSlot != null && ItemStackHelper.areStacksEqual(stackInSlot, inventory[i], fuzzySetting) && IOHelper.canInsertItemToInventory(inv, inventory[i], slot, getFacingDirection().ordinal())) {
supplyingInvCount += stackInSlot.stackSize;
}
}
if (supplyingInvCount < outputFilterItems)
return false;
}
}
return !everythingNull;
}
return false;
}
Aggregations