Package logisticspipes.utils

Examples of logisticspipes.utils.WorldUtil


    //give up and select whatever is right of the current slot
    if(!foundSlot) {
      player.inventory.currentItem = (player.inventory.currentItem + 1) % 9;
    }

    final WorldUtil worldUtil = new WorldUtil(player.worldObj, getPosX(), getPosY(), getPosZ());
    boolean found = false;
    for (final AdjacentTile tile : worldUtil.getAdjacentTileEntities(true)) {
      if(tile instanceof IInventory && !(SimpleServiceLocator.inventoryUtilFactory.getInventoryUtil((IInventory)tile) instanceof ISpecialInsertion)) continue;
      for (ICraftingRecipeProvider provider : SimpleServiceLocator.craftingRecipeProviders) {
        if (provider.canOpenGui(tile.tile)) {
          found = true;
          break;
View Full Code Here


      return;
    }
    if (MainProxy.isClient(container.getWorld())) return;
    super.throttledUpdateEntity();
    if(dummyInventory.getStackInSlot(0) == null) return;
    WorldUtil worldUtil = new WorldUtil(getWorld(), getX(), getY(), getZ());
    for (AdjacentTile tile :  worldUtil.getAdjacentTileEntities(true)){
      if (!(tile.tile instanceof IFluidHandler) || SimpleServiceLocator.pipeInformaitonManager.isPipe(tile.tile)) continue;
      IFluidHandler container = (IFluidHandler) tile.tile;
      if (container.getTankInfo(ForgeDirection.UNKNOWN) == null || container.getTankInfo(ForgeDirection.UNKNOWN).length == 0) continue;
     
      //How much do I want?
View Full Code Here

      return;
    }

    if (MainProxy.isClient(getWorld())) return;
    super.throttledUpdateEntity();
    WorldUtil worldUtil = new WorldUtil(getWorld(), getX(), getY(), getZ());
    for (AdjacentTile tile :  worldUtil.getAdjacentTileEntities(true)){
      if (!(tile.tile instanceof IFluidHandler) || SimpleServiceLocator.pipeInformaitonManager.isPipe(tile.tile)) continue;
      IFluidHandler container = (IFluidHandler) tile.tile;
      if (container.getTankInfo(ForgeDirection.UNKNOWN) == null || container.getTankInfo(ForgeDirection.UNKNOWN).length == 0) continue;
     
      //How much do I want?
View Full Code Here

  }

  public void update() {
    if(SimpleServiceLocator.thermalExpansionProxy.isTE() && this.pipe.getUpgradeManager().hasRFPowerSupplierUpgrade()) {
      //Use Buffer
      WorldUtil worldUtil = new WorldUtil(this.pipe.getWorld(), this.pipe.getX(), this.pipe.getY(), this.pipe.getZ());
      LinkedList<AdjacentTile> adjacent = worldUtil.getAdjacentTileEntities(false);
      float globalNeed = 0;
      float[] need = new float[adjacent.size()];
      int i=0;
      for(AdjacentTile adTile:adjacent) {
        if(SimpleServiceLocator.thermalExpansionProxy.isEnergyHandler(adTile.tile) && this.pipe.canPipeConnect(adTile.tile, adTile.orientation) && SimpleServiceLocator.thermalExpansionProxy.canConnectEnergy(adTile.tile, adTile.orientation.getOpposite())) {
          globalNeed += need[i] = SimpleServiceLocator.thermalExpansionProxy.getMaxEnergyStored(adTile.tile, adTile.orientation.getOpposite()) - SimpleServiceLocator.thermalExpansionProxy.getEnergyStored(adTile.tile, adTile.orientation.getOpposite());
        }
        i++;
      }
      if(globalNeed != 0 && !Float.isNaN(globalNeed)) {
        float fullfillable = Math.min(1, internal_RF_Buffer / globalNeed);
        i = 0;
        for(AdjacentTile adTile:adjacent) {
          if(SimpleServiceLocator.thermalExpansionProxy.isEnergyHandler(adTile.tile) && this.pipe.canPipeConnect(adTile.tile, adTile.orientation) && SimpleServiceLocator.thermalExpansionProxy.canConnectEnergy(adTile.tile, adTile.orientation.getOpposite())) {
            if(internal_RF_Buffer + 1 < need[i] * fullfillable) return;
            int used = SimpleServiceLocator.thermalExpansionProxy.receiveEnergy(adTile.tile, adTile.orientation.getOpposite(), (int) (need[i] * fullfillable), false);
            if(used > 0) {
              //MainProxy.sendPacketToAllWatchingChunk(this.pipe.getX(), this.pipe.getZ(), MainProxy.getDimensionForWorld(this.pipe.getWorld()), PacketHandler.getPacket(PowerPacketLaser.class).setColor(LogisticsPowerProviderTileEntity.RF_COLOR).setPos(this.pipe.getLPPosition()).setRenderBall(true).setDir(adTile.orientation).setLength(0.5F));
              ((LogisticsTileGenericPipe)pipe.container).addLaser(adTile.orientation, 0.5F, LogisticsPowerProviderTileEntity.RF_COLOR, false, true);
              internal_RF_Buffer -= used;
            }
            if(internal_RF_Buffer < 0) {
              internal_RF_Buffer = 0;
              return;
            }
          }
          i++;
        }
      }
      //Rerequest Buffer
      List<Pair<ISubSystemPowerProvider, List<IFilter>>> provider = this.pipe.getRouter().getSubSystemPowerProvider();
      float available = 0;
      outer:
      for(Pair<ISubSystemPowerProvider, List<IFilter>> pair : provider) {
        for(IFilter filter:pair.getValue2()) {
          if(filter.blockPower()) continue outer;
        }
        if(pair.getValue1().usePaused()) continue;
        if(!pair.getValue1().getBrand().equals("RF")) continue;
        available += pair.getValue1().getPowerLevel();
      }
      if(available > 0) {
        float neededPower = INTERNAL_RF_BUFFER_MAX - internal_RF_Buffer;
        if(neededPower > 0) {
          if(this.pipe.useEnergy((int) (neededPower / 100), false)) {
            outer:
            for(Pair<ISubSystemPowerProvider, List<IFilter>> pair : provider) {
              for(IFilter filter:pair.getValue2()) {
                if(filter.blockPower()) continue outer;
              }
              if(pair.getValue1().usePaused()) continue;
              if(!pair.getValue1().getBrand().equals("RF")) continue;
              float requestamount = neededPower * (pair.getValue1().getPowerLevel() / available);
              pair.getValue1().requestPower(this.pipe.getRouterId(), requestamount);
            }
          }
        }
      }
    }
    if(SimpleServiceLocator.IC2Proxy.hasIC2() && this.pipe.getUpgradeManager().getIC2PowerLevel() > 0) {
      //Use Buffer
      WorldUtil worldUtil = new WorldUtil(this.pipe.getWorld(), this.pipe.getX(), this.pipe.getY(), this.pipe.getZ());
      LinkedList<AdjacentTile> adjacent = worldUtil.getAdjacentTileEntities(false);
      float globalNeed = 0;
      float[] need = new float[adjacent.size()];
      int i=0;
      for(AdjacentTile adTile:adjacent) {
        if(SimpleServiceLocator.IC2Proxy.isEnergySink(adTile.tile) && this.pipe.canPipeConnect(adTile.tile, adTile.orientation) && SimpleServiceLocator.IC2Proxy.acceptsEnergyFrom(adTile.tile, this.pipe.container, adTile.orientation.getOpposite())) {
View Full Code Here

TOP

Related Classes of logisticspipes.utils.WorldUtil

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.