Examples of CoreRoutedPipe


Examples of logisticspipes.pipes.basic.CoreRoutedPipe

    List<ExitRoute> exits = sourceRouter.getRoutersOnSide(exitOrientation);
    for(ExitRoute exit:exits) {
      if(exit.containsFlag(PipeRoutingConnectionType.canPowerSubSystemFrom)) { // Find only result (caused by only straight connections)
        int distance = sourceRouter.getDistanceToNextPowerPipe(exit.exitOrientation);
        //MainProxy.sendPacketToAllWatchingChunk(xCoord, zCoord, sourceRouter.getDimension(), PacketHandler.getPacket(PowerPacketLaser.class).setColor(this.getLaserColor()).setPos(sourceRouter.getLPPosition()).setDir(exit.exitOrientation).setRenderBall(true).setLength(distance));
        CoreRoutedPipe pipe = sourceRouter.getPipe();
        if(pipe != null && pipe.container instanceof LogisticsTileGenericPipe) {
          ((LogisticsTileGenericPipe)pipe.container).addLaser(exit.exitOrientation, distance, this.getLaserColor(), false, addBall);
        }
        sourceRouter = exit.destination; // Use new sourceRouter
        if(sourceRouter == destinationRouter) return;
View Full Code Here

Examples of logisticspipes.pipes.basic.CoreRoutedPipe

    }
  }
 
  private boolean checkProvider() {
   
    CoreRoutedPipe thisPipe = this.target.getRouter().getCachedPipe();
    if(thisPipe == null) return false;
    for(Pair<IProvideItems, List<IFilter>> provider : getProviders(this.target.getRouter(), this.getStackItem())) {
      if(this.isDone()) {
        break;
      }
      if(provider.getValue1() == null || provider.getValue1().getRouter() == null || provider.getValue1().getRouter().getPipe() == null) continue;
      if(!thisPipe.sharesInventoryWith(provider.getValue1().getRouter().getPipe())) {
        provider.getValue1().canProvide(this, root.getAllPromissesFor(provider.getValue1(), this.getStackItem()), provider.getValue2());
      }
    }
    return this.isDone();
  }
View Full Code Here

Examples of logisticspipes.pipes.basic.CoreRoutedPipe

    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

Examples of logisticspipes.pipes.basic.CoreRoutedPipe

  }

  private static List<Pair<CraftingTemplate,List<IFilter>>> getCrafters(ItemIdentifier itemToCraft, List<ExitRoute> validDestinations) {
    List<Pair<CraftingTemplate,List<IFilter>>> crafters = new ArrayList<Pair<CraftingTemplate,List<IFilter>>>(validDestinations.size());
    for(ExitRoute r : validDestinations) {
      CoreRoutedPipe pipe = r.destination.getPipe();
      if(r.containsFlag(PipeRoutingConnectionType.canRequestFrom)) {
        if (pipe instanceof ICraftItems){
          CraftingTemplate craftable = ((ICraftItems)pipe).addCrafting(itemToCraft);
          if(craftable!=null) {
            for(IFilter filter: r.filters) {
View Full Code Here

Examples of logisticspipes.pipes.basic.CoreRoutedPipe

        pos.moveForward(dir);
        TileEntity tile = pos.getTileEntity(getWorldObj());
        if(!(tile instanceof LogisticsTileGenericPipe)) continue;
        LogisticsTileGenericPipe tPipe = (LogisticsTileGenericPipe) tile;
        if(!(tPipe.pipe instanceof CoreRoutedPipe)) continue;
        CoreRoutedPipe pipe = (CoreRoutedPipe) tPipe.pipe;
        if(pipe.useEnergy(50)) {
          heat += 5;
          if(heat > 100) {
            heat = 100;
          }
          updateHeat();
          usedEnergy = true;
          break;
        }
      }
      if(!usedEnergy && getWorldObj().getTotalWorldTime() % 5 == 0) {
        heat--;
        if(heat < 0) {
          heat = 0;
        }
        updateHeat();
      }
    } else if(!hasWork && heat > 0) {
      heat--;
      updateHeat();
    }
    if(hasWork && heat >= 100) {
      for(ForgeDirection dir:ForgeDirection.VALID_DIRECTIONS) {
        LPPosition pos = new LPPosition(this);
        pos.moveForward(dir);
        TileEntity tile = pos.getTileEntity(getWorldObj());
        if(!(tile instanceof LogisticsTileGenericPipe)) continue;
        LogisticsTileGenericPipe tPipe = (LogisticsTileGenericPipe) tile;
        if(!(tPipe.pipe instanceof CoreRoutedPipe)) continue;
        CoreRoutedPipe pipe = (CoreRoutedPipe) tPipe.pipe;
        if(pipe.useEnergy(30)) {
          progress += 3;
        } else if(pipe.useEnergy(20)) {
          progress += 2;
        } else if(pipe.useEnergy(10)) {
          progress += 1;
        }
        if(progress >= 100) {
          if(tryCraft()) {
            progress = 0;
View Full Code Here

Examples of logisticspipes.pipes.basic.CoreRoutedPipe

    return new LPPosition(_xCoord, _yCoord, _zCoord);
  }

  @Override
  public CoreRoutedPipe getPipe(){
    CoreRoutedPipe crp = getCachedPipe();
    if(crp != null)
      return crp;
    World worldObj = DimensionManager.getWorld(_dimension);
    if(worldObj == null) {
      return null;
View Full Code Here

Examples of logisticspipes.pipes.basic.CoreRoutedPipe

  /**
   * Rechecks the piped connection to all adjacent routers as well as discover new ones.
   */
  private boolean recheckAdjacent() {
    boolean adjacentChanged = false;
    CoreRoutedPipe thisPipe = getPipe();
    if (thisPipe == null) return false;
    HashMap<CoreRoutedPipe, ExitRoute> adjacent;
    List<Pair<ILogisticsPowerProvider,List<IFilter>>> power;
    List<Pair<ISubSystemPowerProvider,List<IFilter>>> subSystemPower;
    PathFinder finder = new PathFinder(thisPipe.container, Configs.LOGISTICS_DETECTION_COUNT, Configs.LOGISTICS_DETECTION_LENGTH);
    power = finder.powerNodes;
    subSystemPower = finder.subPowerProvider;
    adjacent = finder.result;
   
    for(CoreRoutedPipe pipe : adjacent.keySet()) {
      if(pipe.stillNeedReplace()) {
        return false;
      }
    }
   
    boolean[] oldSideDisconnected = sideDisconnected;
    sideDisconnected = new boolean[6];
    checkSecurity(adjacent);
   
    boolean changed = false;
   
    for(int i=0;i<6;i++) {
      changed |= sideDisconnected[i] != oldSideDisconnected[i];
    }
    if(changed) {
      CoreRoutedPipe pipe = getPipe();
      if (pipe != null) {
        pipe.getWorld().notifyBlocksOfNeighborChange(pipe.getX(), pipe.getY(), pipe.getZ(), pipe.getWorld().getBlock(pipe.getX(), pipe.getY(), pipe.getZ()));
        pipe.refreshConnectionAndRender(false);
      }
      adjacentChanged = true;
    }
   
    if(_adjacent.size() != adjacent.size()) {
      adjacentChanged = true;
    }
   
    for (CoreRoutedPipe pipe : _adjacent.keySet()) {
      if(!adjacent.containsKey(pipe)) {
        adjacentChanged = true;
      }
    }
    if(_powerAdjacent!=null) {
      if(power==null){
        adjacentChanged = true;
      } else {
        for (Pair<ILogisticsPowerProvider,List<IFilter>> provider : _powerAdjacent){
          if(!power.contains(provider))
            adjacentChanged = true;
        }
      }
    }
    if(power!=null){
      if(_powerAdjacent==null) {
        adjacentChanged = true;
      } else {
        for (Pair<ILogisticsPowerProvider,List<IFilter>> provider : power){
          if(!_powerAdjacent.contains(provider))
            adjacentChanged = true;
        }
      }
    }
    if(_subSystemPowerAdjacent!=null) {
      if(subSystemPower==null){
        adjacentChanged = true;
      } else {
        for (Pair<ISubSystemPowerProvider, List<IFilter>> provider : _subSystemPowerAdjacent){
          if(!subSystemPower.contains(provider))
            adjacentChanged = true;
        }
      }
    }
    if(subSystemPower!=null){
      if(_subSystemPowerAdjacent==null) {
        adjacentChanged = true;
      } else {
        for (Pair<ISubSystemPowerProvider, List<IFilter>> provider : subSystemPower){
          if(!_subSystemPowerAdjacent.contains(provider))
            adjacentChanged = true;
        }
      }
    }
    for (Entry<CoreRoutedPipe, ExitRoute> pipe : adjacent.entrySet())  {
      ExitRoute oldExit = _adjacent.get(pipe.getKey());
      if (oldExit==null){
        adjacentChanged = true;
        break;
      }
      ExitRoute newExit = pipe.getValue();
     
      if (!newExit.equals(oldExit))  {
        adjacentChanged = true;
        break;
      }
    }   
    if (adjacentChanged) {
      HashMap<IRouter, ExitRoute> adjacentRouter = new HashMap<IRouter, ExitRoute>();
      EnumSet<ForgeDirection> routedexits = EnumSet.noneOf(ForgeDirection.class);
      EnumMap<ForgeDirection, Integer> subpowerexits = new EnumMap<ForgeDirection, Integer>(ForgeDirection.class);
      for(Entry<CoreRoutedPipe,ExitRoute> pipe:adjacent.entrySet()) {
        adjacentRouter.put(pipe.getKey().getRouter(), pipe.getValue());
        if((pipe.getValue().connectionDetails.contains(PipeRoutingConnectionType.canRouteTo) || pipe.getValue().connectionDetails.contains(PipeRoutingConnectionType.canRequestFrom) && !routedexits.contains(pipe.getValue().exitOrientation))) {
          routedexits.add(pipe.getValue().exitOrientation);
        }
        if(!subpowerexits.containsKey(pipe.getValue().exitOrientation) && pipe.getValue().connectionDetails.contains(PipeRoutingConnectionType.canPowerSubSystemFrom)) {
          subpowerexits.put(pipe.getValue().exitOrientation, PathFinder.messureDistanceToNextRoutedPipe(this.getLPPosition(), pipe.getValue().exitOrientation, pipe.getKey().getWorld()));
        }
      }
      _adjacent = Collections.unmodifiableMap(adjacent);
      _adjacentRouter = Collections.unmodifiableMap(adjacentRouter);
      if(power != null){
View Full Code Here

Examples of logisticspipes.pipes.basic.CoreRoutedPipe

    }
    return adjacentChanged;
  }
 
  private void checkSecurity(HashMap<CoreRoutedPipe, ExitRoute> adjacent) {
    CoreRoutedPipe pipe = getPipe();
    if(pipe == null) return;
    UUID id = pipe.getSecurityID();
    List<CoreRoutedPipe> toRemove = new ArrayList<CoreRoutedPipe>();
    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();
View Full Code Here

Examples of logisticspipes.pipes.basic.CoreRoutedPipe

  @Override
  public boolean checkAdjacentUpdate() {
    boolean blockNeedsUpdate = recheckAdjacent();
    if(!blockNeedsUpdate) return false;

    CoreRoutedPipe pipe = getPipe();
    if (pipe == null) return true;
    pipe.refreshRender(true);
    return true;
  }
View Full Code Here

Examples of logisticspipes.pipes.basic.CoreRoutedPipe

    return false;
  }
 
  @Override
  public LogisticsModule getLogisticsModule() {
    CoreRoutedPipe pipe = this.getPipe();
    if (pipe == null) return null;
    return pipe.getLogisticsModule();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.