Search in sources :

Example 6 with RobotStationPluggable

use of buildcraft.robotics.RobotStationPluggable in project LogisticsPipes by RS485.

the class LPBCTileGenericPipe method getBCPipePluggable.

@Override
public IBCPipePluggable getBCPipePluggable(final ForgeDirection sideHit) {
    final PipePluggable plug = getPipePluggable(sideHit);
    if (plug == null) {
        return null;
    }
    return new IBCPipePluggable() {

        @Override
        public ItemStack[] getDropItems(LogisticsTileGenericPipe container) {
            return plug.getDropItems(container);
        }

        @Override
        public boolean isBlocking() {
            return plug.isBlocking(pipe.container, sideHit);
        }

        @Override
        public Object getOriginal() {
            return plug;
        }

        @Override
        @SideOnly(Side.CLIENT)
        public void renderPluggable(RenderBlocks renderblocks, ForgeDirection dir, int renderPass, int x, int y, int z) {
            if (plug.getRenderer() == null) {
                return;
            }
            plug.getRenderer().renderPluggable(renderblocks, bcPipe, dir, plug, FakeBlock.INSTANCE, renderPass, x, y, z);
        }

        @Override
        public boolean isAcceptingItems(LPTravelingItemServer arrivingItem) {
            if (plug instanceof RobotStationPluggable) {
                return true;
            }
            return false;
        }

        @Override
        public LPTravelingItemServer handleItem(LPTravelingItemServer arrivingItem) {
            DockingStation station = ((RobotStationPluggable) plug).getStation();
            if (!station.isTaken()) {
                return arrivingItem;
            }
            EntityRobotBase robot = station.robotTaking();
            if (!(robot.getBoard() instanceof LogisticsRoutingBoardRobot)) {
                return arrivingItem;
            }
            if (!((LogisticsRoutingBoardRobot) robot.getBoard()).isAcceptsItems()) {
                return arrivingItem;
            }
            DoubleCoordinates robotPos = new DoubleCoordinates(robot);
            if (CoordinateUtils.add(new DoubleCoordinates(LPBCTileGenericPipe.this).center(), sideHit, 0.5).distanceTo(robotPos) > 0.05) {
                // Not at station
                return arrivingItem;
            }
            return ((LogisticsRoutingBoardRobot) robot.getBoard()).handleItem(arrivingItem);
        }
    };
}
Also used : RobotStationPluggable(buildcraft.robotics.RobotStationPluggable) RenderBlocks(net.minecraft.client.renderer.RenderBlocks) DockingStation(buildcraft.api.robots.DockingStation) LogisticsRoutingBoardRobot(logisticspipes.proxy.buildcraft.robots.boards.LogisticsRoutingBoardRobot) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) EntityRobotBase(buildcraft.api.robots.EntityRobotBase) ItemStack(net.minecraft.item.ItemStack) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) LPTravelingItemServer(logisticspipes.transport.LPTravelingItem.LPTravelingItemServer)

Aggregations

RobotStationPluggable (buildcraft.robotics.RobotStationPluggable)6 DockingStation (buildcraft.api.robots.DockingStation)5 PipePluggable (buildcraft.api.transport.pluggable.PipePluggable)5 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)5 EntityRobotBase (buildcraft.api.robots.EntityRobotBase)4 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)4 LogisticsRoutingBoardRobot (logisticspipes.proxy.buildcraft.robots.boards.LogisticsRoutingBoardRobot)4 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)4 TileGenericPipe (buildcraft.transport.TileGenericPipe)3 TileEntity (net.minecraft.tileentity.TileEntity)3 LPTravelingItemServer (logisticspipes.transport.LPTravelingItem.LPTravelingItemServer)2 RedstoneBoardRobotNBT (buildcraft.api.boards.RedstoneBoardRobotNBT)1 RobotEvent (buildcraft.api.events.RobotEvent)1 EntityRobot (buildcraft.robotics.EntityRobot)1 ItemRobot (buildcraft.robotics.ItemRobot)1 BlockGenericPipe (buildcraft.transport.BlockGenericPipe)1 GatePluggable (buildcraft.transport.gates.GatePluggable)1 ArrayList (java.util.ArrayList)1 LogisticsPowerJunctionTileEntity (logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity)1 ConnectionInformation (logisticspipes.proxy.specialconnection.SpecialPipeConnection.ConnectionInformation)1