Search in sources :

Example 6 with PipePluggable

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

the class BlockPipeHolder method isSideSolid.

@Override
public boolean isSideSolid(IBlockState base_state, IBlockAccess world, BlockPos pos, EnumFacing side) {
    TilePipeHolder tile = getPipe(world, pos, false);
    if (tile == null) {
        return false;
    }
    PipePluggable pluggable = tile.getPluggable(side);
    return pluggable != null && pluggable.isSideSolid();
}
Also used : TilePipeHolder(buildcraft.transport.tile.TilePipeHolder) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable)

Example 7 with PipePluggable

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

the class BlockPipeHolder method addCollisionBoxToList.

// Collisions
@Override
public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn, boolean isPistonMoving) {
    TilePipeHolder tile = getPipe(world, pos, false);
    if (tile == null) {
        addCollisionBoxToList(pos, entityBox, collidingBoxes, FULL_BLOCK_AABB);
        return;
    }
    boolean added = false;
    Pipe pipe = tile.getPipe();
    if (pipe != null) {
        addCollisionBoxToList(pos, entityBox, collidingBoxes, BOX_CENTER);
        added = true;
        for (EnumFacing face : EnumFacing.VALUES) {
            float conSize = pipe.getConnectedDist(face);
            if (conSize > 0) {
                AxisAlignedBB aabb = BOX_FACES[face.ordinal()];
                if (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);
                }
                addCollisionBoxToList(pos, entityBox, collidingBoxes, aabb);
            }
        }
    }
    for (EnumFacing face : EnumFacing.VALUES) {
        PipePluggable pluggable = tile.getPluggable(face);
        if (pluggable != null) {
            AxisAlignedBB bb = pluggable.getBoundingBox();
            addCollisionBoxToList(pos, entityBox, collidingBoxes, bb);
            added = true;
        }
    }
    for (EnumWirePart part : tile.getWireManager().parts.keySet()) {
        addCollisionBoxToList(pos, entityBox, collidingBoxes, part.boundingBox);
        added = true;
    }
    for (EnumWireBetween between : tile.getWireManager().betweens.keySet()) {
        addCollisionBoxToList(pos, entityBox, collidingBoxes, between.boundingBox);
        added = true;
    }
    if (!added) {
        addCollisionBoxToList(pos, entityBox, collidingBoxes, FULL_BLOCK_AABB);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) TilePipeHolder(buildcraft.transport.tile.TilePipeHolder) EnumWirePart(buildcraft.api.transport.EnumWirePart) EnumFacing(net.minecraft.util.EnumFacing) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable) Pipe(buildcraft.transport.pipe.Pipe) Vec3d(net.minecraft.util.math.Vec3d) EnumWireBetween(buildcraft.transport.wire.EnumWireBetween)

Example 8 with PipePluggable

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

the class BlockPipeHolder method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    TilePipeHolder tile = getPipe(world, pos, false);
    if (tile == null) {
        return false;
    }
    RayTraceResult trace = rayTrace(world, pos, player);
    if (trace == null) {
        return false;
    }
    EnumFacing realSide = getPartSideHit(trace);
    if (realSide == null) {
        realSide = side;
    }
    if (trace.subHit > 6 && trace.subHit <= 12) {
        PipePluggable existing = tile.getPluggable(realSide);
        if (existing != null) {
            return existing.onPluggableActivate(player, trace, hitX, hitY, hitZ);
        }
    }
    EnumPipePart part = trace.subHit == 0 ? EnumPipePart.CENTER : EnumPipePart.fromFacing(realSide);
    ItemStack held = player.getHeldItem(hand);
    Item item = held.isEmpty() ? null : held.getItem();
    PipePluggable existing = tile.getPluggable(realSide);
    if (item instanceof IItemPluggable && existing == null) {
        IItemPluggable itemPlug = (IItemPluggable) item;
        PipePluggable plug = itemPlug.onPlace(held, tile, realSide, player, hand);
        if (plug == null) {
            return false;
        } else {
            tile.replacePluggable(realSide, plug);
            if (!player.capabilities.isCreativeMode) {
                held.shrink(1);
            }
            return true;
        }
    }
    if (item instanceof ItemWire) {
        EnumWirePart wirePartHit = getWirePartHit(trace);
        EnumWirePart wirePart;
        TilePipeHolder attachTile = tile;
        if (wirePartHit != null) {
            WireNode node = new WireNode(pos, wirePartHit);
            node = node.offset(trace.sideHit);
            wirePart = node.part;
            if (!node.pos.equals(pos)) {
                attachTile = getPipe(world, node.pos, false);
            }
        } else {
            wirePart = EnumWirePart.get((trace.hitVec.x % 1 + 1) % 1 > 0.5, (trace.hitVec.y % 1 + 1) % 1 > 0.5, (trace.hitVec.z % 1 + 1) % 1 > 0.5);
        }
        if (wirePart != null && attachTile != null) {
            boolean attached = attachTile.getWireManager().addPart(wirePart, EnumDyeColor.byMetadata(held.getMetadata()));
            attachTile.scheduleNetworkUpdate(IPipeHolder.PipeMessageReceiver.WIRES);
            if (attached && !player.capabilities.isCreativeMode) {
                held.shrink(1);
            }
            if (attached) {
                return true;
            }
        }
    }
    Pipe pipe = tile.getPipe();
    if (pipe == null) {
        return false;
    }
    if (pipe.behaviour.onPipeActivate(player, trace, hitX, hitY, hitZ, part)) {
        return true;
    }
    if (pipe.flow.onFlowActivate(player, trace, hitX, hitY, hitZ, part)) {
        return true;
    }
    return false;
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) IItemPluggable(buildcraft.api.transport.IItemPluggable) RayTraceResult(net.minecraft.util.math.RayTraceResult) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable) Pipe(buildcraft.transport.pipe.Pipe) TilePipeHolder(buildcraft.transport.tile.TilePipeHolder) Item(net.minecraft.item.Item) ItemWire(buildcraft.transport.item.ItemWire) EnumWirePart(buildcraft.api.transport.EnumWirePart) WireNode(buildcraft.api.transport.WireNode) EnumPipePart(buildcraft.api.core.EnumPipePart) ItemStack(net.minecraft.item.ItemStack)

Example 9 with PipePluggable

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

the class BlockPipeHolder method getBlockFaceShape.

@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face) {
    TilePipeHolder tile = getPipe(world, pos, false);
    if (tile == null) {
        return BlockFaceShape.UNDEFINED;
    }
    PipePluggable pluggable = tile.getPluggable(face);
    return pluggable != null ? pluggable.getBlockFaceShape() : BlockFaceShape.UNDEFINED;
}
Also used : TilePipeHolder(buildcraft.transport.tile.TilePipeHolder) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable)

Example 10 with PipePluggable

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

the class PipePluggableState method writeData.

@Override
public void writeData(ByteBuf data) {
    this.pluggableMatrix.clean();
    for (EnumFacing dir : EnumFacing.VALUES) {
        this.pluggableMatrix.setConnected(dir, pluggables[dir.ordinal()] != null);
    }
    this.pluggableMatrix.writeData(data);
    for (PipePluggable p : pluggables) {
        if (p != null) {
            data.writeShort(PipeManager.pipePluggables.indexOf(p.getClass()));
            p.writeData(data);
        }
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable)

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