Search in sources :

Example 1 with TileAutoWorkbench

use of buildcraft.factory.TileAutoWorkbench in project LogisticsPipes by RS485.

the class AutoWorkbench method importRecipe.

@Override
public boolean importRecipe(TileEntity tile, ItemIdentifierInventory inventory) {
    if (!(tile instanceof TileAutoWorkbench)) {
        return false;
    }
    TileAutoWorkbench bench = (TileAutoWorkbench) tile;
    ItemStack result = bench.craftMatrix.getRecipeOutput();
    if (result == null) {
        return false;
    }
    inventory.setInventorySlotContents(9, result);
    // Import
    for (int i = 0; i < bench.craftMatrix.getSizeInventory(); i++) {
        if (i >= inventory.getSizeInventory() - 2) {
            break;
        }
        final ItemStack newStack = bench.craftMatrix.getStackInSlot(i) == null ? null : bench.craftMatrix.getStackInSlot(i).copy();
        if (newStack != null && newStack.stackSize > 1) {
            newStack.stackSize = 1;
        }
        inventory.setInventorySlotContents(i, newStack);
    }
    inventory.compact_first(9);
    return true;
}
Also used : TileAutoWorkbench(buildcraft.factory.TileAutoWorkbench) ItemStack(net.minecraft.item.ItemStack)

Example 2 with TileAutoWorkbench

use of buildcraft.factory.TileAutoWorkbench in project BuildCraft by BuildCraft.

the class SchematicAutoWorkbench method storeRequirements.

@Override
public void storeRequirements(IBuilderContext context, BlockPos pos) {
    TileAutoWorkbench autoWb = getTile(context, pos);
    if (autoWb != null) {
        ArrayList<ItemStack> rqs = new ArrayList<>();
        rqs.add(new ItemStack(BuildCraftFactory.autoWorkbenchBlock));
        for (IInvSlot slot : InventoryIterator.getIterable(autoWb.craftMatrix, EnumFacing.UP)) {
            ItemStack stack = slot.getStackInSlot();
            if (stack != null) {
                stack = stack.copy();
                stack.stackSize = 1;
                rqs.add(stack);
            }
        }
        storedRequirements = JavaTools.concat(storedRequirements, rqs.toArray(new ItemStack[rqs.size()]));
    }
}
Also used : IInvSlot(buildcraft.api.core.IInvSlot) TileAutoWorkbench(buildcraft.factory.TileAutoWorkbench) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 3 with TileAutoWorkbench

use of buildcraft.factory.TileAutoWorkbench in project BuildCraft by BuildCraft.

the class SchematicAutoWorkbench method placeInWorld.

@Override
public void placeInWorld(IBuilderContext context, BlockPos pos, List<ItemStack> stacks) {
    super.placeInWorld(context, pos, stacks);
    TileAutoWorkbench autoWb = getTile(context, pos);
    if (autoWb != null) {
        for (IInvSlot slot : InventoryIterator.getIterable(autoWb.craftMatrix, EnumFacing.UP)) {
            ItemStack stack = slot.getStackInSlot();
            if (stack != null) {
                stack.stackSize = 1;
            }
        }
    }
}
Also used : IInvSlot(buildcraft.api.core.IInvSlot) TileAutoWorkbench(buildcraft.factory.TileAutoWorkbench) ItemStack(net.minecraft.item.ItemStack)

Aggregations

TileAutoWorkbench (buildcraft.factory.TileAutoWorkbench)3 ItemStack (net.minecraft.item.ItemStack)3 IInvSlot (buildcraft.api.core.IInvSlot)2 ArrayList (java.util.ArrayList)1