use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class TEControl method handleBlockUpdate.
public static void handleBlockUpdate(final World world, final LPWorldInfo info, int x, int y, int z) {
if (info.getWorldTick() < 5) {
return;
}
final DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
if (info.getUpdateQueued().contains(pos)) {
return;
}
if (!pos.blockExists(world)) {
return;
}
final TileEntity tile = pos.getTileEntity(world);
if (SimpleServiceLocator.enderIOProxy.isBundledPipe(tile)) {
QueuedTasks.queueTask(() -> {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
DoubleCoordinates newPos = CoordinateUtils.sum(pos, dir);
if (!newPos.blockExists(world)) {
continue;
}
TileEntity nextTile = newPos.getTileEntity(world);
if (nextTile instanceof LogisticsTileGenericPipe) {
((LogisticsTileGenericPipe) nextTile).scheduleNeighborChange();
}
}
return null;
});
}
if (tile == null || ((ILPTEInformation) tile).getObject() == null) {
return;
}
if (SimpleServiceLocator.pipeInformationManager.isItemPipe(tile) || SimpleServiceLocator.specialtileconnection.isType(tile)) {
info.getUpdateQueued().add(pos);
QueuedTasks.queueTask(() -> {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
DoubleCoordinates newPos = CoordinateUtils.sum(pos, dir);
if (!newPos.blockExists(world)) {
continue;
}
TileEntity nextTile = newPos.getTileEntity(world);
if (nextTile != null && ((ILPTEInformation) nextTile).getObject() != null) {
for (ITileEntityChangeListener listener : new ArrayList<>(((ILPTEInformation) nextTile).getObject().changeListeners)) {
listener.pipeModified(pos);
}
}
}
for (ITileEntityChangeListener listener : new ArrayList<>(((ILPTEInformation) tile).getObject().changeListeners)) {
listener.pipeModified(pos);
}
info.getUpdateQueued().remove(pos);
return null;
});
}
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class LogisticsEventListener method onPlayerLeftClickBlock.
@SubscribeEvent
public void onPlayerLeftClickBlock(final PlayerInteractEvent.RightClickBlock event) {
if (MainProxy.isServer(event.getEntityPlayer().world)) {
WorldCoordinatesWrapper worldCoordinates = new WorldCoordinatesWrapper(event.getEntityPlayer().world, event.getPos());
TileEntity tileEntity = worldCoordinates.getTileEntity();
if (tileEntity instanceof TileEntityChest || SimpleServiceLocator.ironChestProxy.isIronChest(tileEntity)) {
List<WeakReference<AsyncQuicksortModule>> list = worldCoordinates.allNeighborTileEntities().stream().filter(NeighborTileEntity::isLogisticsPipe).filter(adjacent -> ((LogisticsTileGenericPipe) adjacent.getTileEntity()).pipe instanceof PipeLogisticsChassis).filter(adjacent -> ((PipeLogisticsChassis) ((LogisticsTileGenericPipe) adjacent.getTileEntity()).pipe).getPointedOrientation() == adjacent.getOurDirection()).map(adjacent -> (PipeLogisticsChassis) ((LogisticsTileGenericPipe) adjacent.getTileEntity()).pipe).flatMap(chassis -> chassis.getModules().getModules()).filter(logisticsModule -> logisticsModule instanceof AsyncQuicksortModule).map(logisticsModule -> new WeakReference<>((AsyncQuicksortModule) logisticsModule)).collect(Collectors.toList());
if (!list.isEmpty()) {
LogisticsEventListener.chestQuickSortConnection.put(event.getEntityPlayer(), list);
}
}
}
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class RequestSatellitePipeListPacket method processPacket.
@Override
public void processPacket(EntityPlayer player) {
LogisticsTileGenericPipe pipe = this.getPipe(player.getEntityWorld(), LTGPCompletionCheck.PIPE);
if (pipe == null || !(pipe.pipe instanceof CoreRoutedPipe)) {
return;
}
CoreRoutedPipe rPipe = (CoreRoutedPipe) pipe.pipe;
List<Pair<String, UUID>> list;
if (rPipe.getRouter() == null || rPipe.getRouter().getRouteTable() == null) {
return;
}
if (this.isFlag()) {
list = PipeFluidSatellite.AllSatellites.stream().filter(Objects::nonNull).filter(it -> it.getRouter() != null).filter(it -> {
List<List<ExitRoute>> routingTable = rPipe.getRouter().getRouteTable();
return routingTable.size() > it.getRouterId() && routingTable.get(it.getRouterId()) != null && !routingTable.get(it.getRouterId()).isEmpty();
}).sorted(Comparator.comparingDouble(it -> rPipe.getRouter().getRouteTable().get(it.getRouterId()).stream().map(it1 -> it1.distanceToDestination).min(Double::compare).get())).map(it -> new Pair<>(it.getSatellitePipeName(), it.getRouter().getId())).collect(Collectors.toList());
} else {
list = PipeItemsSatelliteLogistics.AllSatellites.stream().filter(Objects::nonNull).filter(it -> it.getRouter() != null).filter(it -> {
List<List<ExitRoute>> routingTable = rPipe.getRouter().getRouteTable();
return routingTable.size() > it.getRouterId() && routingTable.get(it.getRouterId()) != null && !routingTable.get(it.getRouterId()).isEmpty();
}).sorted(Comparator.comparingDouble(it -> rPipe.getRouter().getRouteTable().get(it.getRouterId()).stream().map(it1 -> it1.distanceToDestination).min(Double::compare).get())).map(it -> new Pair<>(it.getSatellitePipeName(), it.getRouter().getId())).collect(Collectors.toList());
}
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(ProvideSatellitePipeListPacket.class).setList(list), player);
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class DiskSetNamePacket method processPacket.
@Override
public void processPacket(EntityPlayer player) {
final LogisticsTileGenericPipe pipe = this.getPipe(player.world);
if (pipe == null) {
return;
}
if (pipe.pipe instanceof PipeItemsRequestLogisticsMk2) {
if (((PipeItemsRequestLogisticsMk2) pipe.pipe).getDisk() == null) {
return;
}
if (!((PipeItemsRequestLogisticsMk2) pipe.pipe).getDisk().getItem().equals(LPItems.disk)) {
return;
}
if (!((PipeItemsRequestLogisticsMk2) pipe.pipe).getDisk().hasTagCompound()) {
((PipeItemsRequestLogisticsMk2) pipe.pipe).getDisk().setTagCompound(new NBTTagCompound());
}
NBTTagCompound nbt = ((PipeItemsRequestLogisticsMk2) pipe.pipe).getDisk().getTagCompound();
nbt.setString("name", getString());
}
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class HUDStopWatchingPacket method processPacket.
@Override
public void processPacket(EntityPlayer player) {
final LogisticsTileGenericPipe pipe = this.getPipe(player.world);
if (pipe == null) {
return;
}
if (pipe.pipe instanceof IWatchingHandler) {
IWatchingHandler handler = (IWatchingHandler) pipe.pipe;
handler.playerStopWatching(player, getInteger());
}
}
Aggregations