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;
}
}
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);
}
}
}
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);
}
}
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();
}
}
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);
}
};
}
Aggregations