Search in sources :

Example 6 with PipeWire

use of buildcraft.api.transport.PipeWire in project BuildCraft by BuildCraft.

the class PipeModelCacheWire method generate.

private static ImmutableList<MutableQuad> generate(PipeWireKeySingle key) {
    PipeWire wire = key.type;
    Vec3d pos = wirePosMap.get(wire);
    boolean isLit = key.on;
    // BCLog.logger.info("generate[" + wire + ", " + isLit + ", " + key.connections + "]");
    TextureAtlasSprite sprite = BuildCraftTransport.instance.wireIconProvider.getIcon(wire, isLit);
    List<MutableQuad> unprocessed = new ArrayList<>();
    Vec3d center = pos;
    Vec3d centerSize = new Vec3d(WIRE_WIDTH, WIRE_WIDTH, WIRE_WIDTH);
    AxisDirection[] directions = wireDirectionMap.get(wire);
    int numFaces = 0;
    for (EnumFacing face : EnumFacing.values()) {
        boolean positive = face.getAxisDirection() == AxisDirection.POSITIVE;
        Axis axis = face.getAxis();
        AxisDirection wireCenter = directions[axis.ordinal()];
        if (key.connections.contains(face)) {
            if (wireCenter == face.getAxisDirection()) {
                numFaces++;
            }
            numFaces++;
            Vec3d start = pos;
            Vec3d end = pos.add(centerSize);
            if (positive) {
                start = VecUtil.replaceValue(start, axis, VecUtil.getValue(start, axis) + WIRE_WIDTH);
                end = VecUtil.replaceValue(end, axis, (double) 1);
            } else {
                start = VecUtil.replaceValue(start, axis, (double) 0);
                end = VecUtil.replaceValue(end, axis, VecUtil.getValue(end, axis) - WIRE_WIDTH);
            }
            renderCuboid(unprocessed, start, end.subtract(start), sprite);
        } else {
            boolean anyOther = false;
            for (EnumFacing face2 : EnumFacing.values()) {
                if (face2.getOpposite() == face) {
                    continue;
                }
                anyOther |= key.connections.contains(face2);
            }
            if (anyOther) {
                continue;
            }
            Vec3d start = pos;
            Vec3d end = pos.add(centerSize);
            if (positive) {
                start = VecUtil.replaceValue(start, axis, VecUtil.getValue(start, axis) + WIRE_WIDTH);
                end = VecUtil.replaceValue(end, axis, (double) CoreConstants.PIPE_MAX_POS);
            } else {
                start = VecUtil.replaceValue(start, axis, (double) CoreConstants.PIPE_MIN_POS);
                end = VecUtil.replaceValue(end, axis, VecUtil.getValue(end, axis) - WIRE_WIDTH);
            }
            Vec3d size = end.subtract(start);
            if (size.lengthVector() > WIRE_WIDTH * 2) {
                renderCuboid(unprocessed, start, size, sprite);
            }
        }
    }
    if (numFaces != 1) {
        renderCuboid(unprocessed, center, centerSize, sprite);
    }
    ImmutableList.Builder<MutableQuad> builder = ImmutableList.builder();
    for (MutableQuad quad : unprocessed) {
        if (isLit)
            quad.lightf(1, 0);
        quad.colourf(1, 1, 1, 1);
        // quad.setCalculatedDiffuse();
        builder.add(quad);
    }
    return builder.build();
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ImmutableList(com.google.common.collect.ImmutableList) EnumFacing(net.minecraft.util.EnumFacing) Vec3d(net.minecraft.util.math.Vec3d) PipeWire(buildcraft.api.transport.PipeWire) AxisDirection(net.minecraft.util.EnumFacing.AxisDirection) Axis(net.minecraft.util.EnumFacing.Axis)

Example 7 with PipeWire

use of buildcraft.api.transport.PipeWire in project BuildCraft by BuildCraft.

the class BlockGenericPipe method stripEquipment.

private boolean stripEquipment(World world, BlockPos pos, EntityPlayer player, Pipe<?> pipe, EnumFacing side) {
    if (!world.isRemote) {
        // Try to strip pluggables first
        EnumFacing nSide = side;
        RaytraceResult rayTraceResult = doRayTrace(world, pos, player);
        if (rayTraceResult != null && rayTraceResult.hitPart != Part.Pipe) {
            nSide = rayTraceResult.sideHit;
        }
        if (pipe.container.hasPipePluggable(nSide)) {
            return pipe.container.setPluggable(nSide, null, player);
        }
        // Try to strip wires second, starting with yellow.
        for (PipeWire color : PipeWire.values()) {
            if (stripWire(pipe, color, player)) {
                return true;
            }
        }
    }
    return false;
}
Also used : PipeWire(buildcraft.api.transport.PipeWire) EnumFacing(net.minecraft.util.EnumFacing)

Example 8 with PipeWire

use of buildcraft.api.transport.PipeWire in project BuildCraft by BuildCraft.

the class Gate method addTriggers.

// TRIGGERS
public void addTriggers(Collection<ITriggerInternal> list) {
    for (PipeWire wire : PipeWire.VALUES) {
        if (pipe.wireSet[wire.ordinal()] && wire.ordinal() < material.maxWireColor) {
            list.add(BuildCraftTransport.triggerPipeWireActive[wire.ordinal()]);
            list.add(BuildCraftTransport.triggerPipeWireInactive[wire.ordinal()]);
        }
    }
// for (GateExpansionController expansion : expansions.values()) {
// expansion.addTriggers(list);
// }
}
Also used : PipeWire(buildcraft.api.transport.PipeWire)

Example 9 with PipeWire

use of buildcraft.api.transport.PipeWire in project BuildCraft by BuildCraft.

the class TransportSiliconRecipes method addGateRecipe.

@Optional.Method(modid = "BuildCraft|Silicon")
private static void addGateRecipe(String materialName, int energyCost, GateDefinition.GateMaterial material, EnumRedstoneChipset chipset, PipeWire... pipeWire) {
    List<ItemStack> temp = new ArrayList<>();
    temp.add(chipset.getStack());
    for (PipeWire wire : pipeWire) {
        temp.add(wire.getStack());
    }
    Object[] inputs = temp.toArray();
    BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:andGate" + materialName, energyCost, ItemGate.makeGateItem(material, GateDefinition.GateLogic.AND), inputs);
    BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:orGate" + materialName, energyCost, ItemGate.makeGateItem(material, GateDefinition.GateLogic.OR), inputs);
}
Also used : PipeWire(buildcraft.api.transport.PipeWire) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Aggregations

PipeWire (buildcraft.api.transport.PipeWire)9 ItemStack (net.minecraft.item.ItemStack)3 EnumFacing (net.minecraft.util.EnumFacing)3 ItemPipeWire (buildcraft.transport.ItemPipeWire)2 ArrayList (java.util.ArrayList)2 ItemBuildCraft (buildcraft.core.lib.items.ItemBuildCraft)1 FakeBlockAccessSingleBlock (buildcraft.core.lib.world.FakeBlockAccessSingleBlock)1 ItemFacade (buildcraft.transport.ItemFacade)1 BlockPipe (buildcraft.transport.block.BlockPipe)1 Time (buildcraft.transport.statements.TriggerClockTimer.Time)1 PipeContents (buildcraft.transport.statements.TriggerPipeContents.PipeContents)1 ImmutableList (com.google.common.collect.ImmutableList)1 List (java.util.List)1 Block (net.minecraft.block.Block)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 Axis (net.minecraft.util.EnumFacing.Axis)1 AxisDirection (net.minecraft.util.EnumFacing.AxisDirection)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 Vec3d (net.minecraft.util.math.Vec3d)1