Examples of LPPosition


Examples of logisticspipes.utils.tuples.LPPosition

        ForgeDirection exitdirection = output;
        if (exitdirection == ForgeDirection.UNKNOWN) {
          exitdirection = input;
        }

        LPPosition position = new LPPosition(container.xCoord + 0.5, container.yCoord + 0.375, container.zCoord + 0.5);

        switch (exitdirection) {
        case DOWN:
          position.moveForward(exitdirection, 0.5);
          break;
        case UP:
          position.moveForward(exitdirection, 0.75);
          break;
        case NORTH:
        case SOUTH:
        case WEST:
        case EAST:
          position.moveForward(exitdirection, 0.625);
          break;
        case UNKNOWN:
        default:
          break;
        }

        LPPosition motion = new LPPosition(0, 0, 0);
        motion.moveForward(exitdirection, getSpeed() * 2F);

        EntityItem entityitem = new EntityItem(worldObj, position.getXD(), position.getYD(), position.getZD(), getItemIdentifierStack().makeNormalStack());

        //entityitem.lifespan = 1200;
        //entityitem.delayBeforeCanPickup = 10;

        //uniformly distributed in -0.005 .. 0.01 to increase bias toward smaller values
        float f3 = worldObj.rand.nextFloat() * 0.015F - 0.005F;
        entityitem.motionX = (float) worldObj.rand.nextGaussian() * f3 + motion.getXD();
        entityitem.motionY = (float) worldObj.rand.nextGaussian() * f3 + motion.getYD();
        entityitem.motionZ = (float) worldObj.rand.nextGaussian() * f3 + motion.getZD();
        itemWasLost();

        return entityitem;
      } else {
        return null;
View Full Code Here

Examples of logisticspipes.utils.tuples.LPPosition

  public String toString() {
    return super.toString() + " (" + this.getX() + ", " + this.getY() + ", " + this.getZ() + ")";
  }

  public LPPosition getLPPosition() {
    return new LPPosition(this);
  }
View Full Code Here

Examples of logisticspipes.utils.tuples.LPPosition

    return  _xCoord == xCoord && _yCoord == yCoord && _zCoord == zCoord;
  }
 
  @Override
  public LPPosition getLPPosition() {
    return new LPPosition(_xCoord, _yCoord, _zCoord);
  }
View Full Code Here

Examples of logisticspipes.utils.tuples.LPPosition

    mainPipe = routingUpdateSourcePipe.getExitRoute().destination.getLPPosition();
    getDebugInformation(mainPipe).nextFlags = routingUpdateSourcePipe.getExitRoute().getFlags();
  }

  public void handlePacket(RoutingUpdateCanidatePipe routingUpdateCanidatePipe) {
    LPPosition pos = routingUpdateCanidatePipe.getExitRoute().destination.getLPPosition();
    canidates.add(routingUpdateCanidatePipe.getExitRoute().destination.getLPPosition());
    //listHUD.add(new HUDRoutingTableDebugProvider(new HUDRoutingTableNewCandateUntrace(routingUpdateCanidatePipe.getExitRoute()), pos));
    getDebugInformation(pos).isNew = true;
    getDebugInformation(pos).newIndex = routingUpdateCanidatePipe.getExitRoute().debug.index;
  }
View Full Code Here

Examples of logisticspipes.utils.tuples.LPPosition

      debugWindow.showInfo(exit.destination.toString(), color);
      debugWindow.showInfo("\n", color);
      for(int j=0;j<2;j++) debugWindow.showInfo("\t", color);
      debugWindow.showInfo(exit.debug.toStringNetwork, color);
      debugWindow.showInfo("\n", color);
      LPPosition pos = exit.destination.getLPPosition();
      getDebugInformation(pos).routes.add(exit);
      getDebugInformation(pos).positions.add(i);
    }
    for(Entry<LPPosition, DebugInformation> entry:HUDPositions.entrySet()) {
      listHUD.add(new HUDRoutingTableDebugProvider(new HUDRoutingTableGeneralInfo(entry.getValue()), entry.getKey()));
View Full Code Here

Examples of logisticspipes.utils.tuples.LPPosition

    IPipeInformationProvider startProvider = SimpleServiceLocator.pipeInformaitonManager.getInformationProviderFor(startPipe);
    if(startProvider == null) {
      return new HashMap<CoreRoutedPipe, ExitRoute>();
    }
    PathFinder newSearch = new PathFinder(maxVisited, maxLength, pathPainter);
    LPPosition p = new LPPosition(startProvider);
    newSearch.setVisited.add(p);
    p.moveForward(startOrientation);
    TileEntity entity = p.getTileEntity(startProvider.getWorld());
    IPipeInformationProvider provider = SimpleServiceLocator.pipeInformaitonManager.getInformationProviderFor(entity);
    if (provider == null) {
      return new HashMap<CoreRoutedPipe, ExitRoute>();
    }
    return newSearch.getConnectedRoutingPipes(provider, connectionType, startOrientation);
View Full Code Here

Examples of logisticspipes.utils.tuples.LPPosition

     
      return foundPipes;
    }
   
    //Visited is checked after, so we can reach the same target twice to allow to keep the shortest path
    setVisited.add(new LPPosition(startPipe));
    distances.put(new LPPosition(startPipe), startPipe.getDistance());
   
    // first check specialPipeConnections (tesseracts, teleports, other connectors)
    List<IPipeInformationProvider> pipez = SimpleServiceLocator.specialpipeconnection.getConnectedPipes(startPipe);
    for (IPipeInformationProvider specialpipe : pipez){
      if (setVisited.contains(new LPPosition(specialpipe))) {
        //Don't go where we have been before
        continue;
      }
      HashMap<CoreRoutedPipe, ExitRoute> result = getConnectedRoutingPipes(specialpipe, connectionFlags, side);
      for (Entry<CoreRoutedPipe, ExitRoute> pipe : result.entrySet()) {
        pipe.getValue().exitOrientation = ForgeDirection.UNKNOWN;
        ExitRoute foundPipe=foundPipes.get(pipe.getKey());
        if (foundPipe == null || (pipe.getValue().distanceToDestination < foundPipe.distanceToDestination)) {
          // New path OR   If new path is better, replace old path
          foundPipes.put(pipe.getKey(), pipe.getValue());
        }
      }
    }
   
    ArrayDeque<Pair<TileEntity,ForgeDirection>> connections = new ArrayDeque<Pair<TileEntity,ForgeDirection>>();
   
    //Recurse in all directions
    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
      if(root && !ForgeDirection.UNKNOWN.equals(side) && !direction.equals(side)) continue;

      // tile may be up to 1 second old, but any neighbour pipe change will cause an immidiate update here, so we know that if it has changed, it isn't a pipe that has done so.
      TileEntity tile = startPipe.getTile(direction);
     
      if (tile == null) continue;
      if(OrientationsUtil.isSide(direction)) {
        if (root && tile instanceof ILogisticsPowerProvider) {
          if(this.powerNodes==null) {
            powerNodes = new ArrayList<Pair<ILogisticsPowerProvider,List<IFilter>>>();
          }
          //If we are a FireWall pipe add our filter to the pipes
          if(startPipe.isFirewallPipe()) {
            powerNodes.add(new Pair<ILogisticsPowerProvider,List<IFilter>>((ILogisticsPowerProvider) tile, new OneList<IFilter>(startPipe.getFirewallFilter())));
          } else {
            powerNodes.add(new Pair<ILogisticsPowerProvider,List<IFilter>>((ILogisticsPowerProvider) tile, Collections.unmodifiableList(new ArrayList<IFilter>(0))));
          }
        }
        if(root && tile instanceof ISubSystemPowerProvider) {
          if(this.subPowerProvider==null) {
            subPowerProvider = new ArrayList<Pair<ISubSystemPowerProvider,List<IFilter>>>();
          }
          //If we are a FireWall pipe add our filter to the pipes
          if(startPipe.isFirewallPipe()) {
            subPowerProvider.add(new Pair<ISubSystemPowerProvider,List<IFilter>>((ISubSystemPowerProvider) tile, new OneList<IFilter>(startPipe.getFirewallFilter())));
          } else {
            subPowerProvider.add(new Pair<ISubSystemPowerProvider,List<IFilter>>((ISubSystemPowerProvider) tile, Collections.unmodifiableList(new ArrayList<IFilter>(0))));
          }
        }
      }
      connections.add(new Pair<TileEntity, ForgeDirection>(tile, direction));
    }
   
    while(!connections.isEmpty()) {
      Pair<TileEntity,ForgeDirection> pair = connections.pollFirst();
      TileEntity tile = pair.getValue1();
      ForgeDirection direction = pair.getValue2();
      EnumSet<PipeRoutingConnectionType> nextConnectionFlags = EnumSet.copyOf(connectionFlags);
      boolean isDirectConnection = false;
      int resistance = 0;
     
      if(root) {
        List<TileEntity> list = SimpleServiceLocator.specialtileconnection.getConnectedPipes(tile);
        if(!list.isEmpty()) {
          for(TileEntity pipe:list) {
            connections.add(new Pair<TileEntity, ForgeDirection>(pipe, direction));
          }
          continue;
        }
        if(!startPipe.getRoutingPipe().getUpgradeManager().hasPowerPassUpgrade()) {
          nextConnectionFlags.remove(PipeRoutingConnectionType.canPowerSubSystemFrom);
        }
      }
     
      if(tile instanceof IInventory && startPipe.isRoutingPipe() && startPipe.getRoutingPipe() instanceof IDirectRoutingConnection) {
        if(SimpleServiceLocator.connectionManager.hasDirectConnection(startPipe.getRoutingPipe().getRouter())) {
          CoreRoutedPipe CRP = SimpleServiceLocator.connectionManager.getConnectedPipe(startPipe.getRoutingPipe().getRouter());
          if(CRP != null) {
            tile = CRP.container;
            isDirectConnection = true;
            resistance = ((IDirectRoutingConnection)startPipe.getRoutingPipe()).getConnectionResistance();
          }
        }
      }
     
      if (tile == null) continue;
     
      IPipeInformationProvider currentPipe = SimpleServiceLocator.pipeInformaitonManager.getInformationProviderFor(tile);
     
      if (currentPipe != null && currentPipe.isInitialised() && (isDirectConnection || SimpleServiceLocator.pipeInformaitonManager.canConnect(startPipe, currentPipe, direction, true))) {
        //TileGenericPipe currentPipe = (TileGenericPipe) tile;
        if (setVisited.contains(new LPPosition(tile))) {
          //Don't go where we have been before
          continue;
        }
        if(side != pair.getValue2() && !root) { //Only straight connections for subsystem power
          nextConnectionFlags.remove(PipeRoutingConnectionType.canPowerSubSystemFrom);
        }
        if(isDirectConnection) {  //ISC doesn't pass power
          nextConnectionFlags.remove(PipeRoutingConnectionType.canPowerFrom);
          nextConnectionFlags.remove(PipeRoutingConnectionType.canPowerSubSystemFrom);
        }
        //Iron, obsidean and liquid pipes will separate networks
        if(currentPipe.divideNetwork()) {
          continue;
        }
        if(currentPipe.powerOnly()) {
          nextConnectionFlags.remove(PipeRoutingConnectionType.canRouteTo);
          nextConnectionFlags.remove(PipeRoutingConnectionType.canRequestFrom);
        }
        if(startPipe.isOnewayPipe()) {
          if(!startPipe.isOutputOpen(direction)) {
            nextConnectionFlags.remove(PipeRoutingConnectionType.canRouteTo);
          }
        }
        if(currentPipe.isOnewayPipe()) {
          nextConnectionFlags.remove(PipeRoutingConnectionType.canPowerSubSystemFrom);
          if(!currentPipe.isOutputOpen(direction.getOpposite())) {
            nextConnectionFlags.remove(PipeRoutingConnectionType.canRequestFrom);
            nextConnectionFlags.remove(PipeRoutingConnectionType.canPowerFrom);
          }
        }

        if(nextConnectionFlags.isEmpty()) {  //don't bother going somewhere we can't do anything with
          continue;
        }

        int beforeRecurseCount = foundPipes.size();
        HashMap<CoreRoutedPipe, ExitRoute> result = getConnectedRoutingPipes(currentPipe, nextConnectionFlags, direction);
        for(Entry<CoreRoutedPipe, ExitRoute> pipeEntry : result.entrySet()) {
          //Update Result with the direction we took
          pipeEntry.getValue().exitOrientation = direction;
          ExitRoute foundPipe = foundPipes.get(pipeEntry.getKey());
          if (foundPipe==null) {
            // New path
            foundPipes.put(pipeEntry.getKey(), pipeEntry.getValue());
            //Add resistance
            pipeEntry.getValue().distanceToDestination += resistance;
          }
          else if (pipeEntry.getValue().distanceToDestination + resistance < foundPipe.distanceToDestination) {
            //If new path is better, replace old path, otherwise do nothing
            foundPipes.put(pipeEntry.getKey(), pipeEntry.getValue());
            //Add resistance
            pipeEntry.getValue().distanceToDestination += resistance;
          }
        }
        if (foundPipes.size() > beforeRecurseCount && pathPainter != null) {
          pathPainter.addLaser(startPipe.getWorld(), new LaserData(startPipe.getX(), startPipe.getY(), startPipe.getZ(), direction, connectionFlags));
        }
      }
    }
    setVisited.remove(new LPPosition(startPipe));
    distances.remove(new LPPosition(startPipe));
    if(startPipe.isRoutingPipe()) { // ie, has the recursion returned to the pipe it started from?
      for(ExitRoute e:foundPipes.values()) {
        e.root = (startPipe.getRoutingPipe()).getRouter();
      }
    }
View Full Code Here

Examples of logisticspipes.utils.tuples.LPPosition

    options.addAll(lasers);
    Iterator<LaserData> iLasers = lasers.iterator();
    while(iLasers.hasNext()) {
      boolean compressed = false;
      LaserData data = iLasers.next();
      LPPosition next = new LPPosition(data.getPosX(), data.getPosY(), data.getPosZ());
      next.moveForward(data.getDir(), data.getLength());
      boolean found = false;
      do {
        found = false;
        Iterator<LaserData> iOptions = options.iterator();
        while(iOptions.hasNext()) {
          LaserData d = iOptions.next();
          if(d.getPosX() == next.getX() && d.getPosY() == next.getY() && d.getPosZ() == next.getZ()) {
            if(data.getDir().equals(d.getDir()) && data.getConnectionType().equals(d.getConnectionType())) {
              data.setLength(data.getLength() + d.getLength());
              next.moveForward(data.getDir(), d.getLength());
              found = true;
              iOptions.remove();
              lasers.remove(d);
              compressed = true;
            } else if(data.getDir().equals(d.getDir())) {
View Full Code Here

Examples of logisticspipes.utils.tuples.LPPosition

  public void stopWatching() {
    MainProxy.sendPacketToServer(PacketHandler.getPacket(HUDStopWatchingPacket.class).setInteger(1).setPosX(getX()).setPosY(getY()).setPosZ(getZ()));
  }
 
  private IInventory getRawInventory(ForgeDirection ori) {
    LPPosition pos = new LPPosition(this.getX(), this.getY(), this.getZ());
    pos.moveForward(ori);
    TileEntity tile = pos.getTileEntity(getWorld());
    if (SimpleServiceLocator.pipeInformaitonManager.isPipe(tile)) return null;
    if (!(tile instanceof IInventory)) return null;
    return InventoryHelper.getInventory((IInventory) tile);
  }
View Full Code Here

Examples of logisticspipes.utils.tuples.LPPosition

  @Override
  public void processPacket(EntityPlayer player) {
    MovingObjectPosition box = FMLClientHandler.instance().getClient().objectMouseOver;
    if(box != null && box.typeOfHit == MovingObjectType.BLOCK) {
      if(!isServer) {
        TileEntity tile = new LPPosition(box.blockX,box.blockY,box.blockZ).getTileEntity(player.getEntityWorld());
        if(tile instanceof LogisticsTileGenericPipe) {
          ((CoreRoutedPipe)((LogisticsTileGenericPipe)tile).pipe).debug.debugThisPipe = !((CoreRoutedPipe)((LogisticsTileGenericPipe)tile).pipe).debug.debugThisPipe;
          if(((CoreRoutedPipe)((LogisticsTileGenericPipe)tile).pipe).debug.debugThisPipe) {
            player.addChatComponentMessage(new ChatComponentText("Debug enabled On Client"));
          } else {
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.