Search in sources :

Example 21 with PipePluggable

use of buildcraft.api.transport.pluggable.PipePluggable in project BuildCraft by BuildCraft.

the class BlockPipeHolder method getSelectedBoundingBox.

@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, BlockPos pos) {
    TilePipeHolder tile = getPipe(world, pos, false);
    if (tile == null) {
        return FULL_BLOCK_AABB;
    }
    RayTraceResult trace = Minecraft.getMinecraft().objectMouseOver;
    if (trace == null || trace.subHit < 0 || !pos.equals(trace.getBlockPos())) {
        // Perhaps we aren't the object the mouse is over
        return FULL_BLOCK_AABB;
    }
    int part = trace.subHit;
    AxisAlignedBB aabb = FULL_BLOCK_AABB;
    if (part == 0) {
        aabb = BOX_CENTER;
    } else if (part < 1 + 6) {
        aabb = BOX_FACES[part - 1];
        Pipe pipe = tile.getPipe();
        if (pipe != null) {
            EnumFacing face = EnumFacing.VALUES[part - 1];
            float conSize = pipe.getConnectedDist(face);
            if (conSize > 0 && conSize != 0.25f) {
                Vec3d center = VecUtil.offset(new Vec3d(0.5, 0.5, 0.5), face, 0.25 + (conSize / 2));
                Vec3d radius = new Vec3d(0.25, 0.25, 0.25);
                radius = VecUtil.replaceValue(radius, face.getAxis(), conSize / 2);
                Vec3d min = center.subtract(radius);
                Vec3d max = center.add(radius);
                aabb = BoundingBoxUtil.makeFrom(min, max);
            }
        }
    } else if (part < 1 + 6 + 6) {
        EnumFacing side = EnumFacing.VALUES[part - 1 - 6];
        PipePluggable pluggable = tile.getPluggable(side);
        if (pluggable != null) {
            aabb = pluggable.getBoundingBox();
        }
    } else if (part < 1 + 6 + 6 + 8) {
        EnumWirePart wirePart = EnumWirePart.VALUES[part - 1 - 6 - 6];
        aabb = wirePart.boundingBox;
    } else if (part < 1 + 6 + 6 + 6 + 8 + 36) {
        EnumWireBetween wireBetween = EnumWireBetween.VALUES[part - 1 - 6 - 6 - 8];
        aabb = wireBetween.boundingBox;
    }
    if (part >= 1 + 6 + 6) {
        return aabb.offset(pos);
    } else {
        return (aabb == FULL_BLOCK_AABB ? aabb : aabb.grow(1 / 32.0)).offset(pos);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) TilePipeHolder(buildcraft.transport.tile.TilePipeHolder) EnumWirePart(buildcraft.api.transport.EnumWirePart) EnumFacing(net.minecraft.util.EnumFacing) RayTraceResult(net.minecraft.util.math.RayTraceResult) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable) Pipe(buildcraft.transport.pipe.Pipe) Vec3d(net.minecraft.util.math.Vec3d) EnumWireBetween(buildcraft.transport.wire.EnumWireBetween) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 22 with PipePluggable

use of buildcraft.api.transport.pluggable.PipePluggable in project BuildCraft by BuildCraft.

the class BlockPipeHolder method removePluggable.

private static void removePluggable(EnumFacing side, TilePipeHolder tile, NonNullList<ItemStack> toDrop) {
    PipePluggable removed = tile.replacePluggable(side, null);
    if (removed != null) {
        removed.onRemove();
        removed.addDrops(toDrop, 0);
    }
}
Also used : PipePluggable(buildcraft.api.transport.pluggable.PipePluggable)

Example 23 with PipePluggable

use of buildcraft.api.transport.pluggable.PipePluggable in project BuildCraft by BuildCraft.

the class ActionPowerPulsar method actionActivate.

@Override
public void actionActivate(EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
    if (source instanceof IGate) {
        IGate gate = (IGate) source;
        IPipeHolder pipe = gate.getPipeHolder();
        PipePluggable plug = pipe.getPluggable(side);
        if (plug instanceof PluggablePulsar) {
            PluggablePulsar pulsar = (PluggablePulsar) plug;
            if (constant) {
                pulsar.enablePulsar();
            } else {
                pulsar.addSinglePulse();
            }
        }
    }
}
Also used : IGate(buildcraft.api.gates.IGate) IPipeHolder(buildcraft.api.transport.pipe.IPipeHolder) PluggablePulsar(buildcraft.transport.plug.PluggablePulsar) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable)

Example 24 with PipePluggable

use of buildcraft.api.transport.pluggable.PipePluggable in project BuildCraft by BuildCraft.

the class RenderPipeHolder method renderPluggables.

private static void renderPluggables(TilePipeHolder pipe, double x, double y, double z, float partialTicks, BufferBuilder bb) {
    for (EnumFacing face : EnumFacing.VALUES) {
        PipePluggable plug = pipe.getPluggable(face);
        if (plug == null) {
            continue;
        }
        renderPlug(plug, x, y, z, partialTicks, bb);
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable)

Example 25 with PipePluggable

use of buildcraft.api.transport.pluggable.PipePluggable in project BuildCraft by BuildCraft.

the class FilterEventHandler method sideCheck.

@PipeEventHandler
public static void sideCheck(PipeEventItem.SideCheck event) {
    for (EnumFacing side : EnumFacing.VALUES) {
        if (!event.isAllowed(side)) {
            continue;
        }
        IPipe neighbour = event.holder.getNeighbourPipe(side);
        if (neighbour == null) {
            continue;
        }
        PipePluggable neighbourPlug = neighbour.getHolder().getPluggable(side.getOpposite());
        PipePluggable atPlug = event.holder.getPluggable(side);
        if (neighbourPlug instanceof PluggableLens) {
            EnumDyeColor colourAt = event.colour;
            if (atPlug instanceof PluggableLens) {
                PluggableLens lens = (PluggableLens) atPlug;
                if (!lens.isFilter) {
                    colourAt = lens.colour;
                }
            }
            PluggableLens lens = (PluggableLens) neighbourPlug;
            if (lens.isFilter) {
                if (colourAt == lens.colour) {
                    event.increasePriority(side);
                } else if (colourAt == null) {
                    event.decreasePriority(side);
                }
            }
        }
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable) IPipe(buildcraft.api.transport.pipe.IPipe) EnumDyeColor(net.minecraft.item.EnumDyeColor) PipeEventHandler(buildcraft.api.transport.pipe.PipeEventHandler)

Aggregations

PipePluggable (buildcraft.api.transport.pluggable.PipePluggable)30 EnumFacing (net.minecraft.util.EnumFacing)17 TilePipeHolder (buildcraft.transport.tile.TilePipeHolder)10 Pipe (buildcraft.transport.pipe.Pipe)6 DockingStation (buildcraft.api.robots.DockingStation)5 EnumWirePart (buildcraft.api.transport.EnumWirePart)5 RobotStationPluggable (buildcraft.robotics.RobotStationPluggable)5 TileEntity (net.minecraft.tileentity.TileEntity)5 EntityRobotBase (buildcraft.api.robots.EntityRobotBase)4 EnumWireBetween (buildcraft.transport.wire.EnumWireBetween)4 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)4 ItemStack (net.minecraft.item.ItemStack)4 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)4 IPipe (buildcraft.api.transport.pipe.IPipe)3 TileGenericPipe (buildcraft.transport.TileGenericPipe)3 LogisticsRoutingBoardRobot (logisticspipes.proxy.buildcraft.robots.boards.LogisticsRoutingBoardRobot)3 Vec3d (net.minecraft.util.math.Vec3d)3 IPipeTile (buildcraft.api.transport.IPipeTile)2 IPipeHolder (buildcraft.api.transport.pipe.IPipeHolder)2