use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class LogisticsTileGenericSubMultiBlock method getMainPipe.
public List<LogisticsTileGenericPipe> getMainPipe() {
if (mainPipe == null) {
mainPipe = new ArrayList<>();
for (DoubleCoordinates pos : mainPipePos) {
TileEntity tile = pos.getTileEntity(getWorldObj());
if (tile instanceof LogisticsTileGenericPipe) {
mainPipe.add((LogisticsTileGenericPipe) tile);
}
}
mainPipe = Collections.unmodifiableList(mainPipe);
}
boolean allInvalid = true;
for (LogisticsTileGenericPipe pipe : mainPipe) {
if (!pipe.isInvalid()) {
allInvalid = false;
break;
}
}
if (mainPipe.isEmpty() || allInvalid) {
getWorldObj().setBlockToAir(xCoord, yCoord, zCoord);
}
if (mainPipe != null) {
return mainPipe;
}
return Collections.emptyList();
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class LogisticsTileGenericSubMultiBlock method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
NBTTagList nbtList = new NBTTagList();
for (DoubleCoordinates pos : mainPipePos) {
NBTTagCompound compound = new NBTTagCompound();
pos.writeToNBT("MainPipePos_", compound);
nbtList.appendTag(compound);
}
nbt.setTag("MainPipePosList", nbtList);
NBTTagList nbtTypeList = new NBTTagList();
for (CoreMultiBlockPipe.SubBlockTypeForShare type : subTypes) {
if (type == null)
continue;
nbtTypeList.appendTag(new NBTTagString(type.name()));
}
nbt.setTag("SubTypeList", nbtTypeList);
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class PipeItemsInvSysConnector method inventoryConnected.
private boolean inventoryConnected() {
for (int i = 0; i < 6; i++) {
ForgeDirection dir = ForgeDirection.values()[i];
DoubleCoordinates p = CoordinateUtils.add(new DoubleCoordinates(this), dir);
TileEntity tile = p.getTileEntity(getWorld());
if (tile instanceof IInventory && this.container.canPipeConnect(tile, dir)) {
return true;
}
}
return false;
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class RoutingUpdateDebugFilters method readData.
@Override
public void readData(LPDataInput input) {
pos = new DoubleCoordinates(input);
filterPositions = new EnumMap<>(PipeRoutingConnectionType.class);
short id;
while ((id = input.readShort()) != -1) {
PipeRoutingConnectionType type = PipeRoutingConnectionType.values[id];
List<List<DoubleCoordinates>> typeFilters = new ArrayList<>();
int length;
while ((length = input.readShort()) != -1) {
List<DoubleCoordinates> linkedFilter = new ArrayList<>();
for (int i = 0; i < length; i++) {
linkedFilter.add(new DoubleCoordinates(input));
}
typeFilters.add(linkedFilter);
}
filterPositions.put(type, typeFilters);
}
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class EnderIOHyperCubeConnection 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 || !SimpleServiceLocator.enderIOProxy.isSendAndReceive(tile)) {
return new ArrayList<>(0);
}
List<? extends TileEntity> connections = SimpleServiceLocator.enderIOProxy.getConnectedHyperCubes(tile);
List<TileEntity> list = new ArrayList<>();
for (TileEntity connected : connections) {
if (!SimpleServiceLocator.enderIOProxy.isSendAndReceive(connected)) {
continue;
}
LogisticsTileGenericPipe pipe = null;
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
DoubleCoordinates p = CoordinateUtils.add(new DoubleCoordinates(connected), direction);
TileEntity canidate = p.getTileEntity(tile.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);
}
}
Aggregations