use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class PipeTransportLogistics method resolveUnroutedDestination.
public RoutingResult resolveUnroutedDestination(LPTravelingItemServer data) {
List<EnumFacing> dirs = new ArrayList<>(Arrays.asList(EnumFacing.VALUES));
dirs.remove(data.input.getOpposite());
Iterator<EnumFacing> iter = dirs.iterator();
while (iter.hasNext()) {
EnumFacing dir = iter.next();
DoubleCoordinates pos = CoordinateUtils.add(getPipe().getLPPosition(), dir);
TileEntity tile = pos.getTileEntity(getWorld());
if (!SimpleServiceLocator.pipeInformationManager.isItemPipe(tile)) {
iter.remove();
} else if (!canPipeConnect(tile, dir)) {
iter.remove();
} else if (tile instanceof LogisticsTileGenericPipe && !((LogisticsTileGenericPipe) tile).canConnect(container, dir.getOpposite(), false)) {
iter.remove();
}
}
if (dirs.isEmpty()) {
return new RoutingResult(null, false);
}
int num = new Random().nextInt(dirs.size());
return new RoutingResult(dirs.get(num), true);
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class PathFinder method messureDistanceToNextRoutedPipe.
public static int messureDistanceToNextRoutedPipe(DoubleCoordinates lpPosition, EnumFacing exitOrientation, World world) {
int dis = 1;
TileEntity tile = lpPosition.getTileEntity(world);
if (tile instanceof LogisticsTileGenericPipe) {
tile = ((LogisticsTileGenericPipe) tile).getNextConnectedTile(exitOrientation);
}
if (tile == null) {
return 0;
}
IPipeInformationProvider info = SimpleServiceLocator.pipeInformationManager.getInformationProviderFor(tile);
while (info != null && !info.isRoutingPipe()) {
tile = info.getNextConnectedTile(exitOrientation);
if (tile == null) {
info = null;
continue;
}
info = SimpleServiceLocator.pipeInformationManager.getInformationProviderFor(tile);
dis++;
}
return dis;
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class TEControl method invalidate.
public static void invalidate(final TileEntity tile) {
final World world = tile.getWorld();
if (!MainProxy.isServer(world)) {
return;
}
if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).isRoutingPipe()) {
return;
}
if (((ILPTEInformation) tile).getObject() != null) {
QueuedTasks.queueTask(() -> {
DoubleCoordinates pos = new DoubleCoordinates(tile);
for (EnumFacing dir : EnumFacing.VALUES) {
DoubleCoordinates newPos = CoordinateUtils.sum(pos, dir);
if (!newPos.blockExists(world)) {
continue;
}
TileEntity nextTile = newPos.getTileEntity(world);
if (nextTile != null && ((ILPTEInformation) nextTile).getObject() != null) {
if (SimpleServiceLocator.pipeInformationManager.isItemPipe(nextTile)) {
SimpleServiceLocator.pipeInformationManager.getInformationProviderFor(nextTile).refreshTileCacheOnSide(dir.getOpposite());
}
}
}
for (ITileEntityChangeListener listener : new ArrayList<>(((ILPTEInformation) tile).getObject().changeListeners)) {
listener.pipeRemoved(pos);
}
return null;
});
}
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class ClientRouter method getPipe.
@Override
public CoreRoutedPipe getPipe() {
World world = MainProxy.proxy.getWorld();
if (world == null) {
return null;
}
TileEntity tile = world.getTileEntity(new BlockPos(_xCoord, _yCoord, _zCoord));
if (!(tile instanceof LogisticsTileGenericPipe)) {
return null;
}
LogisticsTileGenericPipe pipe = (LogisticsTileGenericPipe) tile;
if (!(pipe.pipe instanceof CoreRoutedPipe)) {
return null;
}
return (CoreRoutedPipe) pipe.pipe;
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class PipeFluidSatellite method updateWatchers.
public void updateWatchers() {
final LogisticsTileGenericPipe container = Objects.requireNonNull(getContainer());
CoordinatesPacket packet = PacketHandler.getPacket(SyncSatelliteNamePacket.class).setString(satellitePipeName).setTilePos(container);
MainProxy.sendToPlayerList(packet, localModeWatchers);
MainProxy.sendPacketToAllWatchingChunk(container, packet);
}
Aggregations