use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class PipeItemsInvSysConnector method isConnectedInv.
public boolean isConnectedInv(TileEntity tile) {
for (int i = 0; i < 6; i++) {
ForgeDirection dir = ForgeDirection.values()[i];
DoubleCoordinates p = CoordinateUtils.add(new DoubleCoordinates(this), dir);
TileEntity lTile = p.getTileEntity(getWorld());
if (lTile instanceof IInventory) {
if (lTile == tile) {
return this.container.canPipeConnect(lTile, dir);
}
}
}
return false;
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class RoutingUpdateDebugClosedSet method readData.
@Override
public void readData(LPDataInput input) {
set = input.readEnumSet(PipeRoutingConnectionType.class);
pos = new DoubleCoordinates(input);
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class LogisticsTileGenericSubMultiBlock method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
if (nbt.hasKey("MainPipePos_xPos")) {
mainPipePos.clear();
DoubleCoordinates pos = DoubleCoordinates.readFromNBT("MainPipePos_", nbt);
if (pos != null) {
mainPipePos.add(pos);
}
}
if (nbt.hasKey("MainPipePosList")) {
NBTTagList list = nbt.getTagList("MainPipePosList", new NBTTagCompound().getId());
for (int i = 0; i < list.tagCount(); i++) {
DoubleCoordinates pos = DoubleCoordinates.readFromNBT("MainPipePos_", list.getCompoundTagAt(i));
if (pos != null) {
mainPipePos.add(pos);
}
}
}
if (nbt.hasKey("SubTypeList")) {
NBTTagList list = nbt.getTagList("SubTypeList", new NBTTagString().getId());
subTypes.clear();
for (int i = 0; i < list.tagCount(); i++) {
String name = list.getStringTagAt(i);
CoreMultiBlockPipe.SubBlockTypeForShare type = CoreMultiBlockPipe.SubBlockTypeForShare.valueOf(name);
if (type != null) {
subTypes.add(type);
}
}
}
mainPipe = null;
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class LPRobotConnectionControl method checkAll.
public void checkAll(World world) {
if (!globalAvailableRobots.containsKey(world)) {
return;
}
for (Pair<DoubleCoordinates, ForgeDirection> canidatePos : globalAvailableRobots.get(world)) {
TileEntity connectedPipeTile = canidatePos.getValue1().getTileEntity(world);
if (!(connectedPipeTile instanceof LogisticsTileGenericPipe)) {
continue;
}
LogisticsTileGenericPipe connectedPipe = (LogisticsTileGenericPipe) connectedPipeTile;
if (!connectedPipe.isRoutingPipe()) {
continue;
}
PipePluggable connectedPluggable = ((TileGenericPipe) connectedPipe.tilePart.getOriginal()).getPipePluggable(canidatePos.getValue2());
if (!(connectedPluggable instanceof RobotStationPluggable)) {
continue;
}
DockingStation connectedStation = ((RobotStationPluggable) connectedPluggable).getStation();
if (!connectedStation.isTaken()) {
continue;
}
EntityRobotBase connectedRobot = connectedStation.robotTaking();
if (connectedRobot == null) {
continue;
}
if (!(connectedRobot.getBoard() instanceof LogisticsRoutingBoardRobot)) {
continue;
}
LogisticsRoutingBoardRobot lpBoard = ((LogisticsRoutingBoardRobot) connectedRobot.getBoard());
if (isModified(lpBoard)) {
connectedPipe.getRoutingPipe().triggerConnectionCheck();
}
}
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class LPRobotConnectionControl method isModified.
public boolean isModified(LogisticsRoutingBoardRobot board) {
Set<Pair<DoubleCoordinates, ForgeDirection>> localConnectedRobots = new HashSet<>();
DoubleCoordinates sourceRobotPosition = CoordinateUtils.add(board.getLinkedStationPosition().center(), board.robot.getLinkedStation().side(), 0.5);
IZone zone = board.robot.getZoneToWork();
for (Pair<DoubleCoordinates, ForgeDirection> canidatePos : globalAvailableRobots.get(board.robot.worldObj)) {
DoubleCoordinates canidateRobotPosition = CoordinateUtils.add(new DoubleCoordinates(canidatePos.getValue1()).center(), canidatePos.getValue2(), 0.5);
double distance = canidateRobotPosition.distanceTo(sourceRobotPosition);
boolean isPartOfZone;
if (zone != null) {
isPartOfZone = zone.contains(canidateRobotPosition.getXCoord(), canidateRobotPosition.getYCoord(), canidateRobotPosition.getZCoord());
} else {
isPartOfZone = distance < Configs.MAX_ROBOT_DISTANCE;
}
if (isPartOfZone) {
localConnectedRobots.add(canidatePos);
}
}
if (board.getConnectionDetails().localConnectedRobots.equals(localConnectedRobots)) {
return false;
} else {
board.getConnectionDetails().localConnectedRobots.clear();
board.getConnectionDetails().localConnectedRobots.addAll(localConnectedRobots);
return true;
}
}
Aggregations