use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.
the class RequestTreeNode method getProviders.
private static List<Pair<IProvide, List<IFilter>>> getProviders(IRouter destination, IResource item) {
// get all the routers
BitSet routersIndex = ServerRouter.getRoutersInterestedIn(item);
// get the routing table
List<ExitRoute> validSources = new ArrayList<>();
for (int i = routersIndex.nextSetBit(0); i >= 0; i = routersIndex.nextSetBit(i + 1)) {
IRouter r = SimpleServiceLocator.routerManager.getRouterUnsafe(i, false);
if (!r.isValidCache()) {
//Skip Routers without a valid pipe
continue;
}
List<ExitRoute> e = destination.getDistanceTo(r);
if (e != null) {
validSources.addAll(e);
}
}
// closer providers are good
Collections.sort(validSources, new workWeightedSorter(1.0));
List<Pair<IProvide, List<IFilter>>> providers = new LinkedList<>();
validSources.stream().filter(r -> r.containsFlag(PipeRoutingConnectionType.canRequestFrom)).forEach(r -> {
CoreRoutedPipe pipe = r.destination.getPipe();
if (pipe instanceof IProvide) {
List<IFilter> list = new LinkedList<>();
list.addAll(r.filters);
providers.add(new Pair<>((IProvide) pipe, list));
}
});
return providers;
}
use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.
the class ExitRoute method readRouter.
@SideOnly(Side.CLIENT)
private IRouter readRouter(LPDataInput input) {
DoubleCoordinates pos = new DoubleCoordinates(input);
TileEntity tile = pos.getTileEntity(MainProxy.getClientMainWorld());
if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof CoreRoutedPipe) {
return ((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).getRouter();
}
return null;
}
use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.
the class LogisticsRenderPipe method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTickTime) {
double distance = Math.pow(Minecraft.getMinecraft().thePlayer.lastTickPosX - tileentity.xCoord, 2) + Math.pow(Minecraft.getMinecraft().thePlayer.lastTickPosY - tileentity.yCoord, 2) + Math.pow(Minecraft.getMinecraft().thePlayer.lastTickPosZ - tileentity.zCoord, 2);
if (tileentity instanceof LogisticsTileGenericPipe) {
LogisticsTileGenericPipe pipe = ((LogisticsTileGenericPipe) tileentity);
if (pipe.pipe == null) {
return;
}
if (pipe.pipe instanceof CoreRoutedPipe) {
renderPipeSigns((CoreRoutedPipe) pipe.pipe, x, y, z, partialTickTime);
}
if (LogisticsRenderPipe.config.isUseNewRenderer()) {
LogisticsRenderPipe.secondRenderer.renderTileEntityAt((LogisticsTileGenericPipe) tileentity, x, y, z, partialTickTime, distance);
}
if (LogisticsRenderPipe.config.getRenderPipeContentDistance() * LogisticsRenderPipe.config.getRenderPipeContentDistance() < distance) {
return;
}
bcRenderer.renderWires(pipe, x, y, z);
// dynamically render pluggables (like gates)
bcRenderer.dynamicRenderPluggables(pipe, x, y, z);
if (!pipe.isOpaque()) {
if (pipe.pipe.transport instanceof PipeFluidTransportLogistics) {
renderFluids(pipe.pipe, x, y, z);
}
if (pipe.pipe.transport instanceof PipeTransportLogistics) {
renderSolids(pipe.pipe, x, y, z, partialTickTime);
}
}
}
}
use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.
the class EntrencsTransport method resolveDestination.
@Override
public ForgeDirection resolveDestination(LPTravelingItemServer data) {
if (data.getDestination() < 0 || data.getArrived()) {
if (pipe.getLocalFreqUUID() != null) {
if (pipe.useEnergy(5)) {
for (ExitRoute router : pipe.getRouter().getIRoutersByCost()) {
if (!router.containsFlag(PipeRoutingConnectionType.canRouteTo)) {
continue;
}
CoreRoutedPipe lPipe = router.destination.getPipe();
if (lPipe instanceof PipeItemsSystemDestinationLogistics) {
PipeItemsSystemDestinationLogistics dPipe = (PipeItemsSystemDestinationLogistics) lPipe;
if (dPipe.getTargetUUID() != null) {
if (dPipe.getTargetUUID().equals(pipe.getLocalFreqUUID())) {
data.setDestination(dPipe.getRouter().getSimpleID());
data.setArrived(false);
}
}
}
}
}
}
}
return super.resolveDestination(data);
}
use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.
the class ServerRouter method checkSecurity.
private void checkSecurity(HashMap<CoreRoutedPipe, ExitRoute> adjacent) {
CoreRoutedPipe pipe = getPipe();
if (pipe == null) {
return;
}
UUID id = pipe.getSecurityID();
List<CoreRoutedPipe> toRemove = new ArrayList<>();
if (id != null) {
for (Entry<CoreRoutedPipe, ExitRoute> entry : adjacent.entrySet()) {
if (!entry.getValue().connectionDetails.contains(PipeRoutingConnectionType.canRouteTo) && !entry.getValue().connectionDetails.contains(PipeRoutingConnectionType.canRequestFrom)) {
continue;
}
UUID thatId = entry.getKey().getSecurityID();
if (!(pipe instanceof PipeItemsFirewall)) {
if (thatId == null) {
entry.getKey().insetSecurityID(id);
} else if (!id.equals(thatId)) {
sideDisconnected[entry.getValue().exitOrientation.ordinal()] = true;
}
} else {
if (!(entry.getKey() instanceof PipeItemsFirewall)) {
if (thatId != null && !id.equals(thatId)) {
sideDisconnected[entry.getValue().exitOrientation.ordinal()] = true;
}
}
}
}
toRemove.addAll(adjacent.entrySet().stream().filter(entry -> sideDisconnected[entry.getValue().exitOrientation.ordinal()]).map(Entry<CoreRoutedPipe, ExitRoute>::getKey).collect(Collectors.toList()));
toRemove.forEach(adjacent::remove);
}
}
Aggregations