Examples of ItemIdentifierStack


Examples of logisticspipes.utils.item.ItemIdentifierStack

  private void createPatternRequest(IInventoryUtil invUtil) {
    _service.getDebug().log("Supplier: Start calculating pattern request");
    setRequestFailed(false);
    for(int i=0;i < 9;i++) {
      ItemIdentifierStack needed = dummyInventory.getIDStackInSlot(i);
      if(needed == null) continue;
      if(invUtil.getSizeInventory() <= slotArray[i]) continue;
      ItemStack stack = invUtil.getStackInSlot(slotArray[i]);
      ItemIdentifierStack have = null;
      if(stack != null) {
        have = ItemIdentifierStack.getFromStack(stack);
      }
      int haveCount = 0;
      if(have != null) {
        if(!have.getItem().equals(needed.getItem())) {
          _service.getDebug().log("Supplier: Slot for " + i + ", " + needed + " already taken by " + have);
          setRequestFailed(true);
          continue;
        }
        haveCount = have.getStackSize();
      }
      if( ( _patternMode==PatternMode.Bulk50 && haveCount > needed.getStackSize()/2) ||
          ( _patternMode==PatternMode.Bulk100 && haveCount >= needed.getStackSize())) {
        continue;
      }
     

      Integer requestedCount =  _requestedItems.get(needed.getItem());
      if (requestedCount != null) {
        haveCount += requestedCount;
      }
     
      int neededCount = needed.getStackSize() - haveCount;
      if(neededCount < 1) continue;
     
      ItemIdentifierStack toRequest = new ItemIdentifierStack(needed.getItem(), neededCount);
     
      _service.getDebug().log("Supplier: Missing for slot " + i + ": " + toRequest);

      if(!_service.useEnergy(10)) {
        break;
      }
     
      boolean success = false;
     
      IAdditionalTargetInformation targetInformation = new PatternSupplierTargetInformation(slotArray[i], needed.getStackSize());
     
      if(_patternMode != PatternMode.Full) {
        _service.getDebug().log("Supplier: Requesting partial: " + toRequest);
        neededCount = RequestTree.requestPartial(toRequest, this, targetInformation);
        _service.getDebug().log("Supplier: Requested: " + toRequest.getItem().makeStack(neededCount));
        if(neededCount > 0) {
          success = true;
        }
      } else {
        _service.getDebug().log("Supplier: Requesting: " + toRequest);
        success = RequestTree.request(toRequest, this, null, targetInformation);
        if(success) {
          _service.getDebug().log("Supplier: Request success");
        } else {
          _service.getDebug().log("Supplier: Request failed");
        }
      }
     
      if (success){
        Integer currentRequest = _requestedItems.get(toRequest.getItem());
        if(currentRequest == null) {
          _requestedItems.put(toRequest.getItem(), neededCount);
        } else {
          _requestedItems.put(toRequest.getItem(), currentRequest + neededCount);
        }
      } else {
        setRequestFailed(true);
      }
    }
View Full Code Here

Examples of logisticspipes.utils.item.ItemIdentifierStack

    // got to be a TreeMap, because a TreeSet doesn't have the ability to retrieve the key.
    Set<ItemIdentifierStack> list = new TreeSet<ItemIdentifierStack>();
    for(Entry<ItemIdentifier, List<ItemRoutingInformation>> entry:itemsOnRoute.entrySet()) {
      if(entry.getValue().isEmpty())
        continue;
      ItemIdentifierStack currentStack = new ItemIdentifierStack(entry.getKey(),0);
      for(ItemRoutingInformation e:entry.getValue()) {
        currentStack.setStackSize(currentStack.getStackSize()+e.getItem().getStackSize());
      }
      list.add(currentStack);
    }
    return list;
  }
View Full Code Here

Examples of logisticspipes.utils.item.ItemIdentifierStack

        nextSendMin[dir.ordinal()] = 10;
        continue;
      }

      FluidStack toSend = transport.sideTanks[dir.ordinal()].drain(result.getValue2(), true);
      ItemIdentifierStack liquidContainer = SimpleServiceLocator.logisticsFluidManager.getFluidContainer(toSend);
      IRoutedItem routed = SimpleServiceLocator.routedItemHelper.createNewTravelItem(liquidContainer);
      routed.setDestination(result.getValue1());
      routed.setTransportMode(TransportMode.Passive);
      this.queueRoutedItem(routed, dir);
      nextSendMax[dir.ordinal()] = 100;
View Full Code Here

Examples of logisticspipes.utils.item.ItemIdentifierStack

      _transportLayer = new TransportLayer() {
        @Override
        public void handleItem(IRoutedItem item) {
          PipeBlockRequestTable.this.notifyOfItemArival(item.getInfo());
          if(item.getItemIdentifierStack() != null) {
            ItemIdentifierStack stack = item.getItemIdentifierStack();
            stack.setStackSize(inv.addCompressed(stack.makeNormalStack(), false));
          }
        }
        @Override
        public ForgeDirection itemArrived(IRoutedItem item, ForgeDirection denyed) {
          return null;
View Full Code Here

Examples of logisticspipes.utils.item.ItemIdentifierStack

      }
      if(stackForHud != null) {
        ItemStack t = stackForHud.copy();
        if(t.getItemDamage() == OreDictionary.WILDCARD_VALUE)
          t.setItemDamage(0);
        oreHudList.add(new ItemIdentifierStack(ItemIdentifier.get(t), 1));
      } else {
        oreHudList.add(new ItemIdentifierStack(ItemIdentifier.get(Item.getItemFromBlock(Blocks.fire), 0, null), 1));
      }
    }
  }
View Full Code Here

Examples of logisticspipes.utils.item.ItemIdentifierStack

          FluidStack drained = ((ISpecialTankAccessHandler)handler).drainFrom(pair.getValue1(), order.getValue1(), amountToSend, false);
          if(drained != null && order.getValue1().equals(FluidIdentifier.get(drained))) {
            drained = ((ISpecialTankAccessHandler)handler).drainFrom(pair.getValue1(), order.getValue1(), amountToSend, true);
            int amount = drained.amount;
            amountToSend -= amount;
            ItemIdentifierStack stack = SimpleServiceLocator.logisticsFluidManager.getFluidContainer(drained);
            IRoutedItem item = SimpleServiceLocator.routedItemHelper.createNewTravelItem(stack);
            item.setDestination(order.getValue3().getRouter().getSimpleID());
            item.setTransportMode(TransportMode.Active);
            this.queueRoutedItem(item, pair.getValue2());
            manager.sendAmount(amount);
            if(amountToSend <= 0) break;
          }
        }
      }
      if(fallback) {
        FluidTankInfo[] tanks = ((IFluidHandler)pair.getValue1()).getTankInfo(pair.getValue2().getOpposite());
        if(tanks != null) {
          for(FluidTankInfo tank:tanks) {
            if(tank == null) continue;
            FluidStack liquid;
            if((liquid = tank.fluid) != null && liquid.fluidID != 0) {
              if(order.getValue1().equals(FluidIdentifier.get(liquid))) {
                int amount = Math.min(liquid.amount, amountToSend);
                FluidStack drained = ((IFluidHandler)pair.getValue1()).drain(pair.getValue2().getOpposite(), amount, false);
                if(drained != null && order.getValue1().equals(FluidIdentifier.get(drained))) {
                  drained = ((IFluidHandler)pair.getValue1()).drain(pair.getValue2().getOpposite(), amount, true);
                  while(drained.amount < amountToSend) {
                    FluidStack addition = ((IFluidHandler)pair.getValue1()).drain(pair.getValue2().getOpposite(), amountToSend - drained.amount, false);
                    if(addition != null && order.getValue1().equals(FluidIdentifier.get(addition))) {
                      addition = ((IFluidHandler)pair.getValue1()).drain(pair.getValue2().getOpposite(), amountToSend - drained.amount, true);
                      drained.amount += addition.amount;
                    } else {
                      break;
                    }
                  }
                  amount = drained.amount;
                  amountToSend -= amount;
                  ItemIdentifierStack stack = SimpleServiceLocator.logisticsFluidManager.getFluidContainer(drained);
                  IRoutedItem item = SimpleServiceLocator.routedItemHelper.createNewTravelItem(stack);
                  item.setDestination(order.getValue3().getRouter().getSimpleID());
                  item.setTransportMode(TransportMode.Active);
                  this.queueRoutedItem(item, pair.getValue2());
                  manager.sendAmount(amount);
View Full Code Here

Examples of logisticspipes.utils.item.ItemIdentifierStack

  }
 
  @Override
  public LogisticsOrder fullFill(LogisticsPromise promise, IRequestItems destination, IAdditionalTargetInformation info) {
    spawnParticle(Particles.WhiteParticle, 2);
    return _orderManager.addOrder(new ItemIdentifierStack(promise.item, promise.numberOfItems), destination, RequestType.PROVIDER, info);
  }
View Full Code Here

Examples of logisticspipes.utils.item.ItemIdentifierStack

    displayList.clear();
    displayMap.clear();
    getAllItems(displayMap, new ArrayList<IFilter>(0));
    displayList.ensureCapacity(displayMap.size());
    for(Entry <ItemIdentifier, Integer> item :displayMap.entrySet()) {
      displayList.add(new ItemIdentifierStack(item.getKey(), item.getValue()));
    }
    if(!oldList.equals(displayList)) {
      oldList.clear();
      oldList.ensureCapacity(displayList.size());
      oldList.addAll(displayList);
View Full Code Here

Examples of logisticspipes.utils.item.ItemIdentifierStack

  public int countOnRoute(FluidIdentifier ident) {
    int amount = 0;
    for(Iterator<ItemRoutingInformation> iter = _inTransitToMe.iterator();iter.hasNext();) {
      ItemRoutingInformation next = iter.next();
      ItemIdentifierStack item = next.getItem();
      if(item.getItem().isFluidContainer()) {
        FluidStack liquid = SimpleServiceLocator.logisticsFluidManager.getFluidFromContainer(item);
        if(FluidIdentifier.get(liquid).equals(ident)) {
          amount += liquid.amount;
        }
      }
View Full Code Here

Examples of logisticspipes.utils.item.ItemIdentifierStack

    tree.addPromise(promise);
  }

  @Override
  public LogisticsOrder fullFill(LogisticsPromise promise, IRequestItems destination, IAdditionalTargetInformation info) {
    return _service.getOrderManager().addOrder(new ItemIdentifierStack(promise.item, promise.numberOfItems), destination,RequestType.PROVIDER, info);
  }
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.