public void eventHandler(PipeEventItem.FindDest event) {
    LinkedList<EnumFacing> newOris = new LinkedList<EnumFacing>();

    for (int o = 0; o < 6; ++o) {
      EnumFacing orientation = EnumFacing.VALUES[o];

      // commented out during port from BC 4.2 to 6.1
      // I don't know what the equivalent to the Position argument to filterPossibleMovements() is
      // in the new eventHandler system
      // if(orientation != pos.orientation.getOpposite())
      {
        TileEntity entity = container.getTile(orientation);
        if (entity instanceof IInventory) {
          IInventory inventory = (IInventory) entity;

          if (InventoryUtils.containsItem(true, false, event.item.getItemStack(), inventory)) {
            ITransactor transactor = Transactor.getTransactorFor(entity, orientation.getOpposite());
            if (transactor.add(event.item.getItemStack(), false).stackSize > 0) {
              newOris.add(orientation);
            }
          } else {
            event.destinations.remove(orientation);
          }
        }
      }
    }

    if (!newOris.isEmpty()) {
      event.destinations.clear();
      event.destinations.addAll(newOris);
    } else {

    }
  }
Example #2
0
  @Override
  public ItemStack provideItemsForRequest(int i, ItemStack stack) {
    if (currentBuilder == null) {
      return stack;
    } else if (!(currentBuilder instanceof BptBuilderBlueprint)) {
      return stack;
    } else {
      BptBuilderBlueprint bpt = (BptBuilderBlueprint) currentBuilder;

      if (bpt.neededItems.size() <= i) {
        return stack;
      }

      RequirementItemStack requirement = bpt.neededItems.get(i);

      int qty = quantityMissing(requirement.stack, requirement.size);

      if (qty <= 0) {
        return stack;
      }

      ItemStack toAdd = stack.copy();

      if (qty < toAdd.stackSize) {
        toAdd.stackSize = qty;
      }

      ITransactor t = Transactor.getTransactorFor(this);
      ItemStack added = t.add(toAdd, ForgeDirection.UNKNOWN, true);

      if (added.stackSize >= stack.stackSize) {
        return null;
      } else {
        stack.stackSize -= added.stackSize;
        return stack;
      }
    }
  }