use of com.bluepowermod.tile.tier1.TileProjectTable in project BluePower by Qmunity.
the class ProjectTableOverlayHandler method findInventoryQuantities.
@SuppressWarnings("unchecked")
private void findInventoryQuantities(GuiContainer gui, List<DistributedIngred> ingredStacks) {
for (// work out how much we have to go round
Slot slot : // work out how much we have to go round
(List<Slot>) gui.inventorySlots.inventorySlots) {
if (slot.getHasStack() && (slot.inventory instanceof TileProjectTable || slot.inventory instanceof InventoryPlayer)) {
ItemStack pstack = slot.getStack();
DistributedIngred istack = findIngred(ingredStacks, pstack);
if (istack != null)
istack.invAmount += pstack.stackSize;
}
}
}
use of com.bluepowermod.tile.tier1.TileProjectTable in project BluePower by Qmunity.
the class ProjectTableOverlayHandler method moveIngredients.
@SuppressWarnings("unchecked")
private void moveIngredients(GuiContainer gui, List<IngredientDistribution> assignedIngredients, int quantity) {
for (IngredientDistribution distrib : assignedIngredients) {
ItemStack pstack = distrib.permutation;
int transferCap = quantity * pstack.stackSize;
int transferred = 0;
int destSlotIndex = 0;
Slot dest = distrib.slots[0];
int slotTransferred = 0;
int slotTransferCap = pstack.getMaxStackSize();
for (Slot slot : (List<Slot>) gui.inventorySlots.inventorySlots) {
if (!slot.getHasStack() || !(slot.inventory instanceof TileProjectTable) && !(slot.inventory instanceof InventoryPlayer))
continue;
ItemStack stack = slot.getStack();
if (!InventoryUtils.canStack(stack, pstack))
continue;
FastTransferManager.clickSlot(gui, slot.slotNumber);
int amount = Math.min(transferCap - transferred, stack.stackSize);
for (int c = 0; c < amount; c++) {
FastTransferManager.clickSlot(gui, dest.slotNumber, 1);
transferred++;
slotTransferred++;
if (slotTransferred >= slotTransferCap) {
destSlotIndex++;
if (destSlotIndex == distrib.slots.length) {
dest = null;
break;
}
dest = distrib.slots[destSlotIndex];
slotTransferred = 0;
}
}
FastTransferManager.clickSlot(gui, slot.slotNumber);
if (transferred >= transferCap || dest == null)
break;
}
}
}
Aggregations