Search in sources :

Example 1 with ItemPipeWire

use of buildcraft.transport.ItemPipeWire in project BuildCraft by BuildCraft.

the class AdvancedFacadeRecipe method craft.

@Override
public ItemStack craft(ItemStack input, List<ItemStack> expansions, boolean preview) {
    PipeWire wire = null;
    ItemStack facade = null;
    for (ItemStack stack : expansions) {
        if (wire == null && stack.getItem() instanceof ItemPipeWire) {
            wire = PipeWire.fromOrdinal(stack.getItemDamage());
            if (!preview) {
                stack.stackSize--;
            }
        } else if (facade == null && (stack.getItem() instanceof ItemFacade || stack.getItem() == BuildCraftTransport.pipeWire)) {
            facade = stack;
            if (!preview) {
                stack.stackSize--;
            }
        }
    }
    if (wire != null && facade != null) {
        ItemFacade.FacadeState[] states = ItemFacade.getFacadeStates(input);
        ItemFacade.FacadeState additionalState;
        if (facade.getItem() == BuildCraftTransport.plugItem) {
            additionalState = ItemFacade.FacadeState.createTransparent(wire);
        } else {
            additionalState = ItemFacade.getFacadeStates(facade)[0];
            additionalState = ItemFacade.FacadeState.create(additionalState.state, wire);
        }
        // if in states array exists state with the same wire just override it
        for (int i = 0; i < states.length; i++) {
            if (states[i].wire == wire) {
                states[i] = additionalState;
                return ItemFacade.getFacade(states);
            }
        }
        return ItemFacade.getFacade(JavaTools.concat(states, new ItemFacade.FacadeState[] { additionalState }));
    } else {
        return null;
    }
}
Also used : PipeWire(buildcraft.api.transport.PipeWire) ItemPipeWire(buildcraft.transport.ItemPipeWire) ItemFacade(buildcraft.transport.ItemFacade) ItemStack(net.minecraft.item.ItemStack) ItemPipeWire(buildcraft.transport.ItemPipeWire)

Aggregations

PipeWire (buildcraft.api.transport.PipeWire)1 ItemFacade (buildcraft.transport.ItemFacade)1 ItemPipeWire (buildcraft.transport.ItemPipeWire)1 ItemStack (net.minecraft.item.ItemStack)1