Search in sources :

Example 1 with CraftingFilter

use of buildcraft.lib.inventory.filter.CraftingFilter in project BuildCraft by BuildCraft.

the class TileAdvancedCraftingTable method searchNeighborsForIngredients.

private void searchNeighborsForIngredients() {
    for (IInvSlot slot : InventoryIterator.getIterable(craftingSlots, EnumFacing.UP)) {
        ItemStack ingred = slot.getStackInSlot();
        if (ingred == null) {
            continue;
        }
        IStackFilter filter = new CraftingFilter(ingred);
        if (InvUtils.countItems(invInput, EnumFacing.UP, filter) < InvUtils.countItems(craftingSlots, EnumFacing.UP, filter)) {
            for (EnumFacing side : SEARCH_SIDES) {
                TileEntity tile = getTile(side);
                if (tile instanceof IInventory) {
                    IInventory inv = InvUtils.getInventory((IInventory) tile);
                    ItemStack result = InvUtils.moveOneItem(inv, side.getOpposite(), invInput, side, filter);
                    if (result != null) {
                        return;
                    }
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) IInvSlot(buildcraft.api.core.IInvSlot) IStackFilter(buildcraft.api.core.IStackFilter) CraftingFilter(buildcraft.lib.inventory.filter.CraftingFilter) EnumFacing(net.minecraft.util.EnumFacing) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IInvSlot (buildcraft.api.core.IInvSlot)1 IStackFilter (buildcraft.api.core.IStackFilter)1 CraftingFilter (buildcraft.lib.inventory.filter.CraftingFilter)1 IInventory (net.minecraft.inventory.IInventory)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 EnumFacing (net.minecraft.util.EnumFacing)1