public void ejectAt(
      World world, int x, int y, int z, ForgeDirection direction, ArrayList<ItemStack> itemStacks) {

    TileEntity targetInventory = getTileInDirection(direction);
    for (ItemStack stack : itemStacks) {
      // if there's any stack in our buffer slot, eject it. Why is it
      // there?
      ItemStack currentStack = inventory.getStackInSlot(Slots.buffer);
      if (currentStack != null) {
        BlockUtils.ejectItemInDirection(world, x, y, z, direction, currentStack);
      }

      // clear the buffer slot
      inventory.setInventorySlotContents(Slots.buffer.ordinal(), stack);

      // push the item out into a pipe or inventory
      InventoryUtils.moveItemInto(
          inventory, Slots.buffer.ordinal(), targetInventory, -1, 64, direction, true);
      // if there's anything left for whatever reason (maybe no inventory)
      ItemStack buffer = inventory.getStackInSlot(Slots.buffer);
      if (buffer != null) {
        // eject it
        BlockUtils.ejectItemInDirection(world, x, y, z, direction, buffer);
        inventory.setInventorySlotContents(Slots.buffer.ordinal(), null);
      }
    }
  }
  private ItemStack findStack() {
    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
      IInventory inventory =
          InventoryUtils.getInventory(worldObj, xCoord, yCoord, zCoord, direction);
      if (inventory != null) {
        ItemStack stack = ItemDistribution.removeFromFirstNonEmptySlot(inventory);
        if (stack != null) return stack;
      }
    }

    return null;
  }