Search in sources :

Example 56 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.

the class LogisticsRoutingBoardRobot method insertIntoPipe.

private void insertIntoPipe() {
    TileEntity tile = targetStationPos.getTileEntity(robot.worldObj);
    if (tile instanceof LogisticsTileGenericPipe) {
        startDelegateAI(new ItemInsertionAIRobot(robot, (LogisticsTileGenericPipe) tile, this, targetStationSide.getOpposite()));
    } else {
        dropAndClear();
        startDelegateAI(new AIRobotGotoStation(robot, robot.getLinkedStation()));
        targetStationPos = null;
    }
}
Also used : LogisticsPowerJunctionTileEntity(logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) ItemInsertionAIRobot(logisticspipes.proxy.buildcraft.robots.ai.ItemInsertionAIRobot) AIRobotGotoStation(buildcraft.robotics.ai.AIRobotGotoStation) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe)

Example 57 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.

the class LogisticsRoutingBoardRobot method lpUpdate.

public void lpUpdate() {
    index();
    if (robot.containsItems()) {
        ticksWithContent++;
        if (ticksWithContent > 20 * 2) {
            startTransport();
            ticksWithContent = 0;
        }
    } else {
        ticksWithContent = 0;
        acceptsItems = true;
        if (currentTarget != null) {
            startDelegateAI(new AIRobotGotoStation(robot, robot.getLinkedStation()));
            currentTarget = null;
            refreshRoutingTable();
        } else if (robot.getDockingStation() == null) {
            startDelegateAI(new AIRobotGotoStation(robot, robot.getLinkedStation()));
        }
    }
    IEnergyStorage bat = robot.getBattery();
    int need = bat.getMaxEnergyStored() - bat.getEnergyStored();
    if (need <= 1000) {
        return;
    }
    need = bat.receiveEnergy(need, true);
    TileEntity tile = getLinkedStationPosition().getTileEntity(robot.worldObj);
    if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).isRoutingPipe()) {
        CoreRoutedPipe pipe = ((LogisticsTileGenericPipe) tile).getRoutingPipe();
        boolean energyUsed = false;
        int count = 0;
        while (!energyUsed) {
            if (pipe.useEnergy((int) (need * 1.5D * LogisticsPowerJunctionTileEntity.RFDivisor))) {
                energyUsed = true;
            }
            if (count++ > 5) {
                break;
            }
        }
        if (energyUsed) {
            bat.receiveEnergy(need, false);
        }
    }
}
Also used : LogisticsPowerJunctionTileEntity(logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) AIRobotGotoStation(buildcraft.robotics.ai.AIRobotGotoStation) IEnergyStorage(cofh.api.energy.IEnergyStorage) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Example 58 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.

the class TesseractConnection method getConnections.

@Override
public List<TileEntity> getConnections(TileEntity tile) {
    boolean onlyOnePipe = false;
    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
        DoubleCoordinates p = CoordinateUtils.add(new DoubleCoordinates(tile), direction);
        TileEntity canidate = p.getTileEntity(tile.getWorldObj());
        if (canidate instanceof LogisticsTileGenericPipe && MainProxy.checkPipesConnections(tile, canidate, direction)) {
            if (onlyOnePipe) {
                onlyOnePipe = false;
                break;
            } else {
                onlyOnePipe = true;
            }
        }
    }
    if (!onlyOnePipe) {
        return new ArrayList<>(0);
    }
    List<? extends TileEntity> connections = SimpleServiceLocator.thermalExpansionProxy.getConnectedTesseracts(tile);
    connections.remove(tile);
    List<TileEntity> list = new ArrayList<>();
    for (TileEntity connected : connections) {
        LogisticsTileGenericPipe pipe = null;
        for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
            DoubleCoordinates p = CoordinateUtils.add(new DoubleCoordinates(connected), direction);
            TileEntity canidate = p.getTileEntity(connected.getWorldObj());
            if (canidate instanceof LogisticsTileGenericPipe && MainProxy.checkPipesConnections(connected, canidate, direction)) {
                if (pipe != null) {
                    pipe = null;
                    break;
                } else {
                    pipe = (LogisticsTileGenericPipe) canidate;
                }
            }
        }
        if (pipe != null && pipe.pipe instanceof CoreRoutedPipe) {
            list.add(pipe);
        }
    }
    if (list.size() == 1) {
        return list;
    } else {
        return new ArrayList<>(0);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) ArrayList(java.util.ArrayList) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 59 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.

the class TesseractConnection method transmit.

@Override
public void transmit(TileEntity tile, IRoutedItem data) {
    List<TileEntity> list = getConnections(tile);
    if (list.size() < 1) {
        return;
    }
    TileEntity pipe = list.get(0);
    if (pipe instanceof LogisticsTileGenericPipe) {
        ((CoreRoutedPipe) ((LogisticsTileGenericPipe) pipe).pipe).queueUnroutedItemInformation(data.getItemIdentifierStack().clone(), data.getInfo());
    } else {
        new RuntimeException("Only LP pipes can be next to Tesseracts to queue item information").printStackTrace();
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Example 60 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe 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

LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)115 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)47 TileEntity (net.minecraft.tileentity.TileEntity)45 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)21 EnumFacing (net.minecraft.util.EnumFacing)15 ArrayList (java.util.ArrayList)14 List (java.util.List)12 EntityPlayer (net.minecraft.entity.player.EntityPlayer)10 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)10 BlockPos (net.minecraft.util.math.BlockPos)10 World (net.minecraft.world.World)9 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)9 HashMap (java.util.HashMap)8 LinkedList (java.util.LinkedList)8 PipeBlockRequestTable (logisticspipes.pipes.PipeBlockRequestTable)8 LogisticsPowerJunctionTileEntity (logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity)7 MainProxy (logisticspipes.proxy.MainProxy)7 ExitRoute (logisticspipes.routing.ExitRoute)7 PipeLogisticsChassi (logisticspipes.pipes.PipeLogisticsChassi)6 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)6