Search in sources :

Example 1 with AIRobotGotoStation

use of buildcraft.robotics.ai.AIRobotGotoStation 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 2 with AIRobotGotoStation

use of buildcraft.robotics.ai.AIRobotGotoStation 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 3 with AIRobotGotoStation

use of buildcraft.robotics.ai.AIRobotGotoStation in project LogisticsPipes by RS485.

the class LogisticsRoutingBoardRobot method delegateAIEnded.

@Override
public void delegateAIEnded(AIRobot ai) {
    super.delegateAIEnded(ai);
    if (ai instanceof AIRobotGotoBlock) {
        if (!ai.success()) {
            dropAndClear();
            startDelegateAI(new AIRobotGotoStation(robot, robot.getLinkedStation()));
        } else {
            startDelegateAI(new AIRobotStraightMoveTo(robot, (float) targetStationPos.getXCoord() + 0.5F + targetStationSide.offsetX * 0.5F, (float) targetStationPos.getYCoord() + 0.5F + targetStationSide.offsetY * 0.5F, (float) targetStationPos.getZCoord() + 0.5F + targetStationSide.offsetZ * 0.5F));
        }
    } else if (ai instanceof AIRobotStraightMoveTo) {
        if (!ai.success()) {
            dropAndClear();
            startDelegateAI(new AIRobotGotoStation(robot, robot.getLinkedStation()));
        } else {
            insertIntoPipe();
        }
    } else if (ai instanceof ItemInsertionAIRobot) {
        for (int i = 0; i < robot.getSizeInventory(); i++) {
            robot.setInventorySlotContents(i, null);
        }
        if (!ai.success()) {
            dropAndClear();
        } else {
            items.clear();
        }
        startDelegateAI(new AIRobotGotoStation(robot, robot.getLinkedStation()));
        targetStationPos = null;
    }
}
Also used : ItemInsertionAIRobot(logisticspipes.proxy.buildcraft.robots.ai.ItemInsertionAIRobot) AIRobotStraightMoveTo(buildcraft.robotics.ai.AIRobotStraightMoveTo) AIRobotGotoStation(buildcraft.robotics.ai.AIRobotGotoStation) AIRobotGotoBlock(buildcraft.robotics.ai.AIRobotGotoBlock)

Aggregations

AIRobotGotoStation (buildcraft.robotics.ai.AIRobotGotoStation)3 LogisticsPowerJunctionTileEntity (logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity)2 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)2 ItemInsertionAIRobot (logisticspipes.proxy.buildcraft.robots.ai.ItemInsertionAIRobot)2 TileEntity (net.minecraft.tileentity.TileEntity)2 AIRobotGotoBlock (buildcraft.robotics.ai.AIRobotGotoBlock)1 AIRobotStraightMoveTo (buildcraft.robotics.ai.AIRobotStraightMoveTo)1 IEnergyStorage (cofh.api.energy.IEnergyStorage)1 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)1