Search in sources :

Example 1 with TileProjectTable

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;
        }
    }
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) TileProjectTable(com.bluepowermod.tile.tier1.TileProjectTable) Slot(net.minecraft.inventory.Slot) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) ItemStack(net.minecraft.item.ItemStack) DistributedIngred(codechicken.nei.recipe.DefaultOverlayHandler.DistributedIngred)

Example 2 with TileProjectTable

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;
        }
    }
}
Also used : IngredientDistribution(codechicken.nei.recipe.DefaultOverlayHandler.IngredientDistribution) InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) TileProjectTable(com.bluepowermod.tile.tier1.TileProjectTable) Slot(net.minecraft.inventory.Slot) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) ItemStack(net.minecraft.item.ItemStack)

Aggregations

TileProjectTable (com.bluepowermod.tile.tier1.TileProjectTable)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)2 Slot (net.minecraft.inventory.Slot)2 ItemStack (net.minecraft.item.ItemStack)2 DistributedIngred (codechicken.nei.recipe.DefaultOverlayHandler.DistributedIngred)1 IngredientDistribution (codechicken.nei.recipe.DefaultOverlayHandler.IngredientDistribution)1