Search in sources :

Example 61 with CoreRoutedPipe

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;
}
Also used : SortedSet(java.util.SortedSet) Getter(lombok.Getter) IRouter(logisticspipes.routing.IRouter) IOrderInfoProvider(logisticspipes.routing.order.IOrderInfoProvider) PriorityQueue(java.util.PriorityQueue) IProvide(logisticspipes.interfaces.routing.IProvide) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) ResourceType(logisticspipes.routing.order.IOrderInfoProvider.ResourceType) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Map(java.util.Map) ActiveRequestType(logisticspipes.request.RequestTree.ActiveRequestType) RequestTree.workWeightedSorter(logisticspipes.request.RequestTree.workWeightedSorter) LinkedList(java.util.LinkedList) EnumSet(java.util.EnumSet) IAdditionalTargetInformation(logisticspipes.interfaces.routing.IAdditionalTargetInformation) PipeRoutingConnectionType(logisticspipes.routing.PipeRoutingConnectionType) LinkedLogisticsOrderList(logisticspipes.routing.order.LinkedLogisticsOrderList) Iterator(java.util.Iterator) LogisticsOrderManager(logisticspipes.routing.order.LogisticsOrderManager) Set(java.util.Set) Collectors(java.util.stream.Collectors) ExitRoute(logisticspipes.routing.ExitRoute) ServerRouter(logisticspipes.routing.ServerRouter) IResource(logisticspipes.request.resources.IResource) List(java.util.List) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) IFilter(logisticspipes.interfaces.routing.IFilter) Pair(logisticspipes.utils.tuples.Pair) Entry(java.util.Map.Entry) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) BitSet(java.util.BitSet) Collections(java.util.Collections) ICraft(logisticspipes.interfaces.routing.ICraft) BitSet(java.util.BitSet) ArrayList(java.util.ArrayList) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) LinkedList(java.util.LinkedList) IRouter(logisticspipes.routing.IRouter) IFilter(logisticspipes.interfaces.routing.IFilter) RequestTree.workWeightedSorter(logisticspipes.request.RequestTree.workWeightedSorter) ExitRoute(logisticspipes.routing.ExitRoute) IProvide(logisticspipes.interfaces.routing.IProvide) Pair(logisticspipes.utils.tuples.Pair)

Example 62 with CoreRoutedPipe

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 63 with CoreRoutedPipe

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);
            }
        }
    }
}
Also used : PipeFluidTransportLogistics(logisticspipes.transport.PipeFluidTransportLogistics) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) PipeTransportLogistics(logisticspipes.transport.PipeTransportLogistics)

Example 64 with CoreRoutedPipe

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);
}
Also used : PipeItemsSystemDestinationLogistics(logisticspipes.pipes.PipeItemsSystemDestinationLogistics) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) ExitRoute(logisticspipes.routing.ExitRoute)

Example 65 with CoreRoutedPipe

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);
    }
}
Also used : LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule) PriorityQueue(java.util.PriorityQueue) Quartet(logisticspipes.utils.tuples.Quartet) Particles(logisticspipes.pipefxhandlers.Particles) MainProxy(logisticspipes.proxy.MainProxy) ILogisticsPowerProvider(logisticspipes.api.ILogisticsPowerProvider) Configs(logisticspipes.config.Configs) StackTraceUtil(logisticspipes.utils.StackTraceUtil) Map(java.util.Map) ILPTEInformation(logisticspipes.asm.te.ILPTEInformation) EnumSet(java.util.EnumSet) ITileEntityChangeListener(logisticspipes.asm.te.ITileEntityChangeListener) EnumMap(java.util.EnumMap) FluidResource(logisticspipes.request.resources.FluidResource) CacheHolder(logisticspipes.utils.CacheHolder) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) Set(java.util.Set) LPTickHandler(logisticspipes.ticks.LPTickHandler) UUID(java.util.UUID) DictResource(logisticspipes.request.resources.DictResource) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Collectors(java.util.stream.Collectors) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) Info(logisticspipes.utils.StackTraceUtil.Info) List(java.util.List) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) IFilter(logisticspipes.interfaces.routing.IFilter) Pair(logisticspipes.utils.tuples.Pair) Entry(java.util.Map.Entry) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) ItemResource(logisticspipes.request.resources.ItemResource) Setter(lombok.Setter) Getter(lombok.Getter) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) HashMap(java.util.HashMap) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ISubSystemPowerProvider(logisticspipes.interfaces.ISubSystemPowerProvider) AccessLevel(lombok.AccessLevel) IRoutingDebugAdapter(logisticspipes.interfaces.IRoutingDebugAdapter) LPTileEntityObject(logisticspipes.asm.te.LPTileEntityObject) PathFinder(logisticspipes.routing.pathfinder.PathFinder) OneList(logisticspipes.utils.OneList) WeakReference(java.lang.ref.WeakReference) LinkedList(java.util.LinkedList) LPConstants(logisticspipes.LPConstants) DimensionManager(net.minecraftforge.common.DimensionManager) RoutingTableUpdateThread(logisticspipes.ticks.RoutingTableUpdateThread) Iterator(java.util.Iterator) World(net.minecraft.world.World) IResource(logisticspipes.request.resources.IResource) Lock(java.util.concurrent.locks.Lock) PipeItemsFirewall(logisticspipes.pipes.PipeItemsFirewall) TileEntity(net.minecraft.tileentity.TileEntity) BitSet(java.util.BitSet) Collections(java.util.Collections) Entry(java.util.Map.Entry) PipeItemsFirewall(logisticspipes.pipes.PipeItemsFirewall) ArrayList(java.util.ArrayList) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) UUID(java.util.UUID)

Aggregations

CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)68 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)43 TileEntity (net.minecraft.tileentity.TileEntity)22 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)16 ExitRoute (logisticspipes.routing.ExitRoute)15 ArrayList (java.util.ArrayList)14 LinkedList (java.util.LinkedList)13 IRouter (logisticspipes.routing.IRouter)11 Pair (logisticspipes.utils.tuples.Pair)10 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)10 List (java.util.List)9 HashMap (java.util.HashMap)8 IFilter (logisticspipes.interfaces.routing.IFilter)8 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)7 Map (java.util.Map)6 PipeRoutingConnectionType (logisticspipes.routing.PipeRoutingConnectionType)6 World (net.minecraft.world.World)6 BitSet (java.util.BitSet)5 Collections (java.util.Collections)5 EnumSet (java.util.EnumSet)5