Package logisticspipes.routing

Examples of logisticspipes.routing.IRouter


  public ForgeDirection readForgeDirection() throws IOException {
    return ForgeDirection.values()[in.read()];
  }
 
  public ExitRoute readExitRoute(World world) throws IOException {
    IRouter destination = this.readIRouter(world);
    IRouter root = this.readIRouter(world);
    ForgeDirection exitOri = this.readForgeDirection();
    ForgeDirection insertOri = this.readForgeDirection();
    EnumSet<PipeRoutingConnectionType> connectionDetails = this.readEnumSet(PipeRoutingConnectionType.class);
    int distanceToDestination = this.readInt();
    int destinationDistanceToRoot = this.readInt();
View Full Code Here


  private IHUDModuleRenderer HUD = new HUDCCBasedQuickSort(this);
 
  private void createSinkMessage(int slot, ItemIdentifierStack stack) {
    List<CCSinkResponder> respones = new ArrayList<CCSinkResponder>();
    IRouter sourceRouter = this._service.getRouter();
    if (sourceRouter == null) return;
    BitSet routersIndex = ServerRouter.getRoutersInterestedIn(null); // get only pipes with generic interest
    List<ExitRoute> validDestinations = new ArrayList<ExitRoute>(); // get the routing table
    for (int i = routersIndex.nextSetBit(0); i >= 0; i = routersIndex.nextSetBit(i+1)) {
      IRouter r = SimpleServiceLocator.routerManager.getRouterUnsafe(i, false);
      List<ExitRoute> exits = sourceRouter.getDistanceTo(r);
      if (exits!=null) {
        for(ExitRoute e:exits) {
          if(e.containsFlag(PipeRoutingConnectionType.canRouteTo))
            validDestinations.add(e);
View Full Code Here

  private boolean handle(IInventoryUtil invUtil, int slot, List<CCSinkResponder> list) {
    if(list.isEmpty()) return false;
    ItemIdentifier ident = list.get(0).getStack().getItem();
    ItemStack stack = invUtil.getStackInSlot(slot);
    if(stack == null || !ItemIdentifier.get(stack).equals(ident)) return false;
    final IRouter source = this._service.getRouter();
    List<Triplet<Integer, Integer, CCSinkResponder>> posibilities = new ArrayList<Triplet<Integer, Integer, CCSinkResponder>>();
    for(CCSinkResponder sink:list) {
      if(!sink.isDone()) continue;
      if(sink.getCanSink() < 1) continue;
      IRouter r = SimpleServiceLocator.routerManager.getRouter(sink.getRouterId());
      if(r == null) continue;
      List<ExitRoute> ways = source.getDistanceTo(r);
      int minDistance = Integer.MAX_VALUE;
      outer:
      for(ExitRoute route: ways) {
View Full Code Here

    int slotSentCount = 0;
    //cork the compressor
    SimpleServiceLocator.serverBufferHandler.setPause(true);
    while(firstRouter != -1 && slotSentCount < inventorySlotsToUpdatePerTick){
      routersNeedingUpdate.clear(firstRouter);
      IRouter currentRouter = rm.getRouterUnsafe(firstRouter, false);
      if(currentRouter != null) {
        CoreRoutedPipe pipe = currentRouter.getCachedPipe();
        if(pipe!=null)
          slotSentCount += pipe.sendQueueChanged(true);
      }
      firstRouter = routersNeedingUpdate.nextSetBit(firstRouter);
    }
View Full Code Here

      if (available == 0) continue;
     
      int wanted = Math.min(available, stack.getStackSize());
      wanted = Math.min(wanted, maxCount);
      wanted = Math.min(wanted, item.getMaxStackSize());
      IRouter dRtr = SimpleServiceLocator.routerManager.getRouterUnsafe(destination,false);
      if(dRtr == null) {
        _orderManager.sendFailed();
        return 0;
      }
      SinkReply reply = LogisticsManager.canSink(dRtr, null, true, stack.getItem(), null, true,false);
View Full Code Here

  private List<IFluidProvider> getFluidProviders() {
    BitSet routersIndex = ServerRouter.getRoutersInterestedIn(liquid.getItemIdentifier());
    List<IFluidProvider> providers = new LinkedList<IFluidProvider>();
    for (int i = routersIndex.nextSetBit(0); i >= 0; i = routersIndex.nextSetBit(i+1)) {
      IRouter r = SimpleServiceLocator.routerManager.getRouterUnsafe(i,false);
      if(r.getPipe() instanceof IFluidProvider){
        List<ExitRoute> e = target.getRouter().getDistanceTo(r);
        if (e!=null) {
          for(ExitRoute route: e) {
            if(!route.filters.isEmpty()) continue;
            CoreRoutedPipe pipe = route.destination.getPipe();
View Full Code Here

      return 0;
    }
    int wanted = Math.min(available, stack.getStackSize());
    wanted = Math.min(wanted, maxCount);
    wanted = Math.min(wanted, item.getMaxStackSize());
    IRouter dRtr = SimpleServiceLocator.routerManager.getRouterUnsafe(destination,false);
    if(dRtr == null) {
      _service.getOrderManager().sendFailed();
      return 0;
    }
    SinkReply reply = LogisticsManager.canSink(dRtr, null, true, stack.getItem(), null, true, false);
View Full Code Here

        for(Entry<Integer, Float> order:orders.entrySet()) {
          float toSend = order.getValue() * fullfullratio;
          if(toSend > internalStorage) {
            toSend = internalStorage;
          }
          IRouter destinationRouter = SimpleServiceLocator.routerManager.getRouter(order.getKey());
          if(destinationRouter != null && destinationRouter.getPipe() != null) {
            WorldUtil util = new WorldUtil(getWorldObj(), xCoord, yCoord, zCoord);
            outerTiles:
            for(AdjacentTile adjacent: util.getAdjacentTileEntities(false)) {
              if(adjacent.tile instanceof LogisticsTileGenericPipe) {
                if(((LogisticsTileGenericPipe)adjacent.tile).pipe instanceof CoreRoutedPipe) {
                  if(((CoreRoutedPipe)((LogisticsTileGenericPipe)adjacent.tile).pipe).stillNeedReplace()) continue;
                  IRouter sourceRouter = ((CoreRoutedPipe)((LogisticsTileGenericPipe)adjacent.tile).pipe).getRouter();
                  if(sourceRouter != null) {
                    outerRouters:
                    for(ExitRoute exit:sourceRouter.getDistanceTo(destinationRouter)) {
                      if(exit.containsFlag(PipeRoutingConnectionType.canPowerSubSystemFrom)) {
                        for(IFilter filter:exit.filters) {
                          if(filter.blockPower()) continue outerRouters;
                        }
                        //MainProxy.sendPacketToAllWatchingChunk(xCoord, zCoord, sourceRouter.getDimension(), PacketHandler.getPacket(PowerPacketLaser.class).setColor(this.getLaserColor()).setPos(sourceRouter.getLPPosition()).setDir(adjacent.orientation.getOpposite()).setReverse(true).setLength(1));
                        CoreRoutedPipe pipe = sourceRouter.getPipe();
                        if(pipe != null && pipe.container instanceof LogisticsTileGenericPipe) {
                          ((LogisticsTileGenericPipe)pipe.container).addLaser(adjacent.orientation.getOpposite(), 1, this.getLaserColor(), true, true);
                        }
                        try {
                          currentlyUsedPos.add(sourceRouter.getLPPosition());
                          sendPowerLaserPackets(sourceRouter, destinationRouter, exit.exitOrientation, exit.exitOrientation != adjacent.orientation);
                          currentlyUsedPos.remove(sourceRouter.getLPPosition());
                        } catch(StackOverflowError error) {
                          for(LPPosition pos:currentlyUsedPos) {
                            System.out.println(pos);
                          }
                          throw error;
View Full Code Here

    // get all the routers
    BitSet routersIndex = ServerRouter.getRoutersInterestedIn(item);
    List<ExitRoute> validSources = new ArrayList<ExitRoute>(); // get the routing table
    for (int i = routersIndex.nextSetBit(0); i >= 0; i = routersIndex.nextSetBit(i+1)) {
      IRouter r = SimpleServiceLocator.routerManager.getRouterUnsafe(i,false);

      if(!r.isValidCache()) continue; //Skip Routers without a valid pipe

      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<IProvideItems,List<IFilter>>> providers = new LinkedList<Pair<IProvideItems,List<IFilter>>>();
    for(ExitRoute r : validSources) {
      if(r.containsFlag(PipeRoutingConnectionType.canRequestFrom)) {
        CoreRoutedPipe pipe = r.destination.getPipe();
        if (pipe instanceof IProvideItems) {
          List<IFilter> list = new LinkedList<IFilter>();
          list.addAll(r.filters);
          providers.add(new Pair<IProvideItems,List<IFilter>>((IProvideItems)pipe, list));
View Full Code Here

   
    // get all the routers
    BitSet routersIndex = ServerRouter.getRoutersInterestedIn(this.getStackItem());
    List<ExitRoute> validSources = new ArrayList<ExitRoute>(); // get the routing table
    for (int i = routersIndex.nextSetBit(0); i >= 0; i = routersIndex.nextSetBit(i+1)) {
      IRouter r = SimpleServiceLocator.routerManager.getRouterUnsafe(i,false);

      if(!r.isValidCache()) continue; //Skip Routers without a valid pipe

      List<ExitRoute> e = this.target.getRouter().getDistanceTo(r);
      if (e!=null) validSources.addAll(e);
    }
    workWeightedSorter wSorter = new workWeightedSorter(0); // distance doesn't matter, because ingredients have to be delivered to the crafter, and we can't tell how long that will take.
View Full Code Here

TOP

Related Classes of logisticspipes.routing.IRouter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.