コード例 #1
0
  @Override
  public ItemStack getCraftingResult(IInventory inventory) {
    ItemStack skinStack = null;
    ItemStack blackStack = null;

    for (int slotId = 0; slotId < inventory.getSizeInventory(); slotId++) {
      ItemStack stack = inventory.getStackInSlot(slotId);
      if (stack != null) {
        Item item = stack.getItem();

        if (item == ModItems.equipmentSkin && EquipmentNBTHelper.stackHasSkinData(stack)) {
          if (skinStack != null) {
            return null;
          }
          skinStack = stack;
        } else if (item == ModItems.equipmentSkinTemplate
            & !EquipmentNBTHelper.stackHasSkinData(stack)) {
          if (blackStack != null) {
            return null;
          }
          blackStack = stack;
        } else {
          return null;
        }
      }
    }

    if (skinStack != null && blackStack != null) {
      ItemStack returnStack = new ItemStack(ModItems.equipmentSkin, 1);
      SkinPointer skinData = EquipmentNBTHelper.getSkinPointerFromStack(skinStack);
      EquipmentNBTHelper.addSkinDataToStack(returnStack, skinData.skinType, skinData.skinId, false);
      return returnStack;
    }
    return null;
  }
  /** Inserts one item from the hopper into the inventory the hopper is pointing at. */
  private boolean insertItemToInventory() {
    IInventory iinventory = this.getOutputInventory();

    if (iinventory == null) {
      return false;
    } else {
      for (int i = 0; i < this.getSizeInventory(); ++i) {
        if (this.getStackInSlot(i) != null) {
          ItemStack itemstack = this.getStackInSlot(i).copy();
          ItemStack itemstack1 =
              insertStack(
                  iinventory,
                  this.decrStackSize(i, 1),
                  Facing.oppositeSide[
                      BlockHopper.getDirectionFromMetadata(this.getBlockMetadata())]);

          if (itemstack1 == null || itemstack1.stackSize == 0) {
            iinventory.onInventoryChanged();
            return true;
          }

          this.setInventorySlotContents(i, itemstack);
        }
      }

      return false;
    }
  }
コード例 #3
0
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotNum) {
    ItemStack itemCopy = null;
    Slot slot = (Slot) this.inventorySlots.get(slotNum);

    if (slot != null && slot.getHasStack()) {
      ItemStack item = slot.getStack();
      itemCopy = item.copy();

      if (!(item.getItem() instanceof ItemPotion)) return null;

      if (slotNum < inventory.getSizeInventory()) {
        if (!this.mergeItemStack(
            item, inventory.getSizeInventory(), this.inventorySlots.size(), true)) {
          return null;
        }
      } else if (!this.mergeItemStack(item, 0, inventory.getSizeInventory(), false)) {
        return null;
      }

      if (item.stackSize == 0) {
        slot.putStack((ItemStack) null);
      } else {
        slot.onSlotChanged();
      }
    }

    return itemCopy;
  }
コード例 #4
0
  public static boolean requestElements(
      EntityPlayer player, ElementList list, int purityRequired, boolean doit) {
    if (player.capabilities.isCreativeMode) return true;

    IInventory mainInv = player.inventory;

    int invSize = mainInv.getSizeInventory();

    for (int i = 0; i < invSize; i++) {
      ItemStack stackInSlot = mainInv.getStackInSlot(i);

      if (stackInSlot != null && stackInSlot.getItem() instanceof IElementProvider) {
        IElementProvider elementItem = (IElementProvider) stackInSlot.getItem();
        if (elementItem.getPurity(player, stackInSlot) < purityRequired) continue;
        ElementList els = elementItem.getElements(player, stackInSlot);
        if (els.size() != 0) {
          ItemStack newStack = elementItem.consumeElements(player, stackInSlot, list, doit);
          if (newStack.stackSize <= 0) mainInv.setInventorySlotContents(i, null);
          else mainInv.setInventorySlotContents(i, newStack);

          if (list.size() == 0) return true;
        }
      }
    }
    return false;
  }
コード例 #5
0
  public static void DropItems(TileEntity tileEntity) {
    if (!(tileEntity instanceof IInventory)) return;

    IInventory inventory = (IInventory) tileEntity;

    if (inventory != null) DropItems(tileEntity, 0, inventory.getSizeInventory() - 1);
  }
コード例 #6
0
ファイル: vase_black.java プロジェクト: Techead13/ModJam
 private void dropItems(World world, int x, int y, int z) {
   Random rand = new Random();
   TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
   if (!(tileEntity instanceof IInventory)) {
     return;
   }
   IInventory inventory = (IInventory) tileEntity;
   for (int i = 0; i < inventory.getSizeInventory(); i++) {
     ItemStack item = inventory.getStackInSlot(i);
     if (item != null && item.stackSize > 0) {
       float rx = rand.nextFloat() * 0.8F + 0.1F;
       float ry = rand.nextFloat() * 0.8F + 0.1F;
       float rz = rand.nextFloat() * 0.8F + 0.1F;
       EntityItem entityItem =
           new EntityItem(
               world,
               x + rx,
               y + ry,
               z + rz,
               new ItemStack(item.itemID, item.stackSize, item.getItemDamage()));
       if (item.hasTagCompound()) {
         entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
       }
       float factor = 0.05F;
       entityItem.motionX = rand.nextGaussian() * factor;
       entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
       entityItem.motionZ = rand.nextGaussian() * factor;
       world.spawnEntityInWorld(entityItem);
       item.stackSize = 0;
     }
   }
 }
コード例 #7
0
ファイル: BlockFL.java プロジェクト: Vexatos/FloodLights
 protected void dropInventory(World world, int x, int y, int z) {
   TileEntity tileEntity = world.getTileEntity(x, y, z);
   if (!(tileEntity instanceof IInventory)) {
     return;
   }
   IInventory inventory = (IInventory) tileEntity;
   for (int i = 0; i < inventory.getSizeInventory(); i++) {
     ItemStack itemStack = inventory.getStackInSlot(i);
     if (itemStack != null && itemStack.stackSize > 0) {
       Random rand = new Random();
       float dX = rand.nextFloat() * 0.8F + 0.1F;
       float dY = rand.nextFloat() * 0.8F + 0.1F;
       float dZ = rand.nextFloat() * 0.8F + 0.1F;
       EntityItem entityItem = new EntityItem(world, x + dX, y + dY, z + dZ, itemStack.copy());
       if (itemStack.hasTagCompound()) {
         entityItem
             .getEntityItem()
             .setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
       }
       float factor = 0.05F;
       entityItem.motionX = rand.nextGaussian() * factor;
       entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
       entityItem.motionZ = rand.nextGaussian() * factor;
       world.spawnEntityInWorld(entityItem);
       itemStack.stackSize = 0;
     }
   }
 }
コード例 #8
0
  /* ISPECIALINVENTORY */
  @Override
  public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {

    if (!this.isLinked()) return 0;

    IInventory inventory = getOrCreateTradeInventory();
    ItemStack tradegood = inventory.getStackInSlot(TradeStation.SLOT_TRADEGOOD);

    // Special handling for paper
    if (stack.getItem() == Items.paper)
      // Handle paper as resource if its not the trade good or pumped in from above or below
      if ((tradegood != null && tradegood.getItem() != Items.paper)
          || from == ForgeDirection.DOWN
          || from == ForgeDirection.UP)
        return StackUtils.addToInventory(
            stack, inventory, doAdd, TradeStation.SLOT_LETTERS_1, TradeStation.SLOT_LETTERS_COUNT);

    // Special handling for stamps
    if (stack.getItem() instanceof IStamps)
      // Handle stamps as resource if its not the trade good or pumped in from above or below
      if ((tradegood != null && !(tradegood.getItem() instanceof IStamps))
          || from == ForgeDirection.DOWN
          || from == ForgeDirection.UP)
        return StackUtils.addToInventory(
            stack, inventory, doAdd, TradeStation.SLOT_STAMPS_1, TradeStation.SLOT_STAMPS_COUNT);

    // Everything else
    if (tradegood == null) return 0;

    if (!tradegood.isItemEqual(stack)) return 0;

    return StackUtils.addToInventory(
        stack, inventory, doAdd, TradeStation.SLOT_INPUTBUF_1, TradeStation.SLOT_BUFFER_COUNT);
  }
コード例 #9
0
  @Override
  public ItemStack removeItem(int maxRemove, ItemStack type) {

    if (maxRemove <= 0) {
      return null;
    }

    int[] slots = getSlots();
    if (slots == null) {
      return null;
    }

    for (int i : slots) {
      ItemStack s = getSlotContents(i);
      if (ItemHelper.itemsEqualWithMetadata(s, type) && canRemoveItem(s, i)) {
        int toRemove = Math.min(s.stackSize, maxRemove);
        s.stackSize -= toRemove;
        ItemStack removed = s.copy();
        removed.stackSize = toRemove;
        if (s.stackSize > 0) {
          _inv.setInventorySlotContents(i, s);
        } else {
          _inv.setInventorySlotContents(i, null);
        }
        return removed;
      }
    }
    return null;
  }
コード例 #10
0
  @Override
  public ItemStack removeItem(int maxRemove) {

    if (maxRemove <= 0) {
      return null;
    }

    int[] slots = getSlots();
    if (slots == null) {
      return null;
    }

    for (int i : slots) {
      ItemStack s = getSlotContents(i);
      if (s != null && canRemoveItem(s, i)) {
        int toRemove = Math.min(s.stackSize, maxRemove);
        s.stackSize -= toRemove;
        ItemStack removed = s.copy();
        removed.stackSize = toRemove;
        if (s.stackSize > 0) {
          _inv.setInventorySlotContents(i, s);
        } else {
          _inv.setInventorySlotContents(i, null);
        }
        _inv.markDirty();
        return removed;
      }
    }
    return null;
  }
コード例 #11
0
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
    ItemStack stack = null;
    Slot slot = (Slot) inventorySlots.get(slotID);

    // null checks and checks if the item can be stacked (maxStackSize > 1)
    if (slot != null && slot.getHasStack()) {
      ItemStack stackInSlot = slot.getStack();
      stack = stackInSlot.copy();

      // merges the item into player inventory since its in the tileEntity
      if (slotID < tileEntity.getSizeInventory()) {
        if (!this.mergeItemStack(
            stackInSlot, tileEntity.getSizeInventory(), this.inventorySlots.size(), true)) {
          return null;
        }
      }
      // merge into tileEntity inventory, since it is in player's inventory
      else if (!this.mergeItemStack(stackInSlot, 0, tileEntity.getSizeInventory(), false)) {
        return null;
      }

      if (stackInSlot.stackSize == 0) {
        slot.putStack(null);
      } else {
        slot.onSlotChanged();
      }
    }
    return stack;
  }
コード例 #12
0
  public ContainerSaltFridge(IInventory par1IInventory, IInventory par2IInventory) {
    this.fridgeInventory = par2IInventory;
    this.numRows = par2IInventory.getSizeInventory() / 9;
    par2IInventory.openChest();
    int i = (this.numRows - 4) * 18;
    int j;
    int k;

    for (j = 0; j < this.numRows; ++j) {
      for (k = 0; k < 9; ++k) {
        this.addSlotToContainer(new Slot(par2IInventory, k + j * 9, 8 + k * 18, 18 + j * 18));
      }
    }

    for (j = 0; j < 3; ++j) {
      for (k = 0; k < 9; ++k) {
        this.addSlotToContainer(
            new Slot(par1IInventory, k + j * 9 + 9, 8 + k * 18, 103 + j * 18 + i));
      }
    }

    for (j = 0; j < 9; ++j) {
      this.addSlotToContainer(new Slot(par1IInventory, j, 8 + j * 18, 161 + i));
    }
  }
コード例 #13
0
  public static InvStack takeTopStack(IInventory inventory, int side) {
    if (!(inventory instanceof ISidedInventory)) {
      inventory = checkChestInv(inventory);

      for (int i = inventory.getSizeInventory() - 1; i >= 0; i--) {
        if (inventory.getStackInSlot(i) != null) {
          ItemStack toSend = inventory.getStackInSlot(i).copy();
          return new InvStack(inventory, i, toSend);
        }
      }
    } else {
      ISidedInventory sidedInventory = (ISidedInventory) inventory;
      int[] slots =
          sidedInventory.getAccessibleSlotsFromSide(
              ForgeDirection.getOrientation(side).getOpposite().ordinal());

      if (slots != null && slots.length != 0) {
        for (int get = slots.length - 1; get >= 0; get--) {
          int slotID = slots[get];

          if (sidedInventory.getStackInSlot(slotID) != null) {
            ItemStack toSend = sidedInventory.getStackInSlot(slotID);

            if (sidedInventory.canExtractItem(
                slotID, toSend, ForgeDirection.getOrientation(side).getOpposite().ordinal())) {
              return new InvStack(inventory, slotID, toSend);
            }
          }
        }
      }
    }

    return null;
  }
コード例 #14
0
  public ContainerChest(IInventory p_i45801_1_, IInventory p_i45801_2_, EntityPlayer p_i45801_3_) {
    this.field_75155_e = p_i45801_2_;
    this.field_75154_f = p_i45801_2_.func_70302_i_() / 9;
    p_i45801_2_.func_174889_b(p_i45801_3_);
    int var4 = (this.field_75154_f - 4) * 18;

    int var5;
    int var6;
    for (var5 = 0; var5 < this.field_75154_f; ++var5) {
      for (var6 = 0; var6 < 9; ++var6) {
        this.func_75146_a(new Slot(p_i45801_2_, var6 + var5 * 9, 8 + var6 * 18, 18 + var5 * 18));
      }
    }

    for (var5 = 0; var5 < 3; ++var5) {
      for (var6 = 0; var6 < 9; ++var6) {
        this.func_75146_a(
            new Slot(p_i45801_1_, var6 + var5 * 9 + 9, 8 + var6 * 18, 103 + var5 * 18 + var4));
      }
    }

    for (var5 = 0; var5 < 9; ++var5) {
      this.func_75146_a(new Slot(p_i45801_1_, var5, 8 + var5 * 18, 161 + var4));
    }
  }
コード例 #15
0
 public float checkTemps(IInventory inv) {
   float temp = 0;
   float[] temp1 = new float[inv.getSizeInventory()];
   for (int i = 0; i < inv.getSizeInventory(); i++) {
     ItemStack is = inv.getStackInSlot(i);
     if (is != null
         && is.hasTagCompound()
         && !is.getItem().getUnlocalizedName(is).contains("Clay")) {
       if (is.getTagCompound().hasKey("temperature")) {
         temp1[i] = is.getTagCompound().getFloat("temperature");
         if (temp1[i] < TFC_ItemHeat.getMeltingPoint(is)) {
           return (float) -1;
         }
       } else {
         return (float) -1;
       }
     } else if (is == null) {
       temp1[i] = -1;
     }
   }
   int temp2 = 0;
   for (int i = 0; i < inv.getSizeInventory(); i++) {
     if (temp1[i] >= 0) {
       temp += temp1[i];
       temp2++;
     }
   }
   if (temp2 > 0) {
     temp /= temp2;
   }
   return temp;
 }
コード例 #16
0
 public boolean getHasError() {
   if (idea.getStackInSlot(0) == null) return true;
   if (idea.getStackInSlot(0).stackTagCompound.hasKey(Constants.NBT_IDEA) == false) return true;
   if (idea.getStackInSlot(0).stackTagCompound.hasKey(Constants.NBT_REFINED) == false) return true;
   if (idea.getStackInSlot(0).stackTagCompound.getInteger(Constants.NBT_REFINED) < 3) return true;
   return false;
 }
コード例 #17
0
  public static StorageChunk cutWorldBB(World worldObj, AxisAlignedBB bb) {
    StorageChunk chunk = StorageChunk.copyWorldBB(worldObj, bb);
    for (int x = (int) bb.minX; x <= bb.maxX; x++) {
      for (int z = (int) bb.minZ; z <= bb.maxZ; z++) {
        for (int y = (int) bb.minY; y <= bb.maxY; y++) {

          // Workaround for dupe
          TileEntity tile = worldObj.getTileEntity(x, y, z);
          if (tile instanceof IInventory) {
            IInventory inv = (IInventory) tile;
            for (int i = 0; i < inv.getSizeInventory(); i++) {
              inv.setInventorySlotContents(i, null);
            }
          }

          worldObj.setBlock(x, y, z, Blocks.air, 0, 2);
        }
      }
    }

    // Carpenter's block's dupe
    for (Object entity : worldObj.getEntitiesWithinAABB(EntityItem.class, bb.expand(5, 5, 5))) {
      ((Entity) entity).setDead();
    }

    return chunk;
  }
コード例 #18
0
 public int[] getSizeInventorySide(int side) {
   IInventory inventory = getOrCreateTradeInventory();
   if (slotIndices == null) {
     slotIndices = new int[inventory.getSizeInventory()];
     for (int i = 0; i < inventory.getSizeInventory(); i++) slotIndices[i] = i;
   }
   return slotIndices;
 }
コード例 #19
0
  @Override
  public ItemStack pullItem(ForgeDirection side, boolean doPull) {
    int xo = xCoord + side.offsetX;
    int yo = yCoord + side.offsetY;
    int zo = zCoord + side.offsetZ;

    TileEntity t = worldObj.getBlockTileEntity(xo, yo, zo);

    if (t instanceof IInventory) {
      if (t instanceof ISpecialInventory) {
        ISpecialInventory isi = (ISpecialInventory) t;
        ItemStack[] items = isi.extractItem(doPull, side.getOpposite(), 1);
        if (items != null && items.length > 0) return items[0];
      } else if (t instanceof ISidedInventory) {
        ISidedInventory isi = (ISidedInventory) t;
        int[] slots = isi.getAccessibleSlotsFromSide(side.getOpposite().ordinal());

        for (int i = 0; i < slots.length; i++) {
          ItemStack pulled = isi.getStackInSlot(slots[i]);
          if (pulled != null
              && isi.canExtractItem(slots[i], pulled, side.getOpposite().ordinal())) {
            ItemStack result = null; // pulled.copy().splitStack(1);
            // pulled.stackSize--;
            // isi.setInventorySlotContents(slots[i], pulled);
            // if(pulled.stackSize <= 0) isi.setInventorySlotContents(slots[i], null);
            if (doPull) {
              result = isi.decrStackSize(slots[i], 1);
              isi.onInventoryChanged();
            } else {
              result = pulled.copy().splitStack(1);
            }
            return result;
          }
        }
      } else {
        IInventory ii = (IInventory) t;

        for (int i = 0; i < ii.getSizeInventory(); i++) {
          ItemStack pulled = ii.getStackInSlot(i);
          if (pulled != null) {
            ItemStack result = null;
            // pulled.stackSize--;
            // ii.setInventorySlotContents(i, pulled);
            // if(pulled.stackSize <= 0)ii.setInventorySlotContents(i, null);
            if (doPull) {
              result = ii.decrStackSize(i, 1);
              ii.onInventoryChanged();
            } else {
              result = pulled.copy().splitStack(1);
            }
            return result;
          }
        }
      }
    }

    return null;
  }
コード例 #20
0
 // Sets the result in the output slot depending on if there's a pattern in the input and on which
 // pattern was selected
 public void updateResult() {
   // no pattern :(
   if (craftMatrix.getStackInSlot(0) == null || output == null) {
     craftResult.setInventorySlotContents(0, null);
   } else {
     // set pattern from selection (or null if no selection)
     craftResult.setInventorySlotContents(0, output.copy());
   }
 }
コード例 #21
0
 public static ItemStack addToEmptyInventorySlot(IInventory inventory, int slot, ItemStack stack) {
   if (!inventory.isItemValidForSlot(slot, stack)) {
     return stack;
   }
   int stackLimit = inventory.getInventoryStackLimit();
   inventory.setInventorySlotContents(
       slot, copyStackWithAmount(stack, Math.min(stack.stackSize, stackLimit)));
   return stackLimit >= stack.stackSize ? null : stack.splitStack(stack.stackSize - stackLimit);
 }
コード例 #22
0
 @Override
 public void onCraft(IInventory inventory) {
   for (int slotId = 0; slotId < inventory.getSizeInventory(); slotId++) {
     ItemStack stack = inventory.getStackInSlot(slotId);
     Item item = stack.getItem();
     if (item == ModItems.equipmentSkinTemplate & !EquipmentNBTHelper.stackHasSkinData(stack)) {
       inventory.decrStackSize(slotId, 1);
     }
   }
 }
コード例 #23
0
ファイル: ItemHelper.java プロジェクト: Bunsan/MerchantsTFC
  public static final int getItemStackMaxQuantity(ItemStack itemStack, IInventory inventory) {
    Item item = itemStack.getItem();

    if (item instanceof IFood)
      return (int) ((IFood) itemStack.getItem()).getFoodMaxWeight(itemStack);

    if (inventory instanceof TEIngotPile) return inventory.getInventoryStackLimit();

    return Math.min(itemStack.getMaxStackSize(), inventory.getInventoryStackLimit());
  }
コード例 #24
0
 /** Call when a container block is broken to drop the entire inv into the world */
 public static void dropContainerBlockInventory(World world, int x, int y, int z) {
   TileEntity tileEntity = world.getTileEntity(x, y, z);
   if (!(tileEntity instanceof IInventory)) {
     return;
   }
   IInventory inv = (IInventory) tileEntity;
   for (int i = 0; i < inv.getSizeInventory(); ++i) {
     spawnItemWithRandom(world, inv.getStackInSlotOnClosing(i), x, y, z);
   }
 }
コード例 #25
0
  @Override
  public void buildBlock(BptSlotInfo slot, IBptContext context) {
    super.buildBlock(slot, context);

    IInventory inv = (IInventory) context.world().getTileEntity(slot.x, slot.y, slot.z);

    for (int i = 0; i < inv.getSizeInventory(); ++i) {
      inv.setInventorySlotContents(i, null);
    }
  }
コード例 #26
0
 private void checkInventoryStatus(int cx, int cy, int cz) {
   TileEntity tileEntity = worldObj.getTileEntity(cx, cy, cz);
   if (tileEntity instanceof IInventory) {
     IInventory inventory = (IInventory) tileEntity;
     if (inventory.getSizeInventory() > 0) {
       inventories.add(new InvBlockInfo(new Coordinate(cx, cy, cz), inventory.getSizeInventory()));
       notifyBlockUpdate();
     }
   }
 }
コード例 #27
0
 public String getInfoMessage() {
   if (idea.getStackInSlot(0) == null) return "Need idea";
   if (idea.getStackInSlot(0).stackTagCompound.hasKey(Constants.NBT_IDEA) == false)
     return "Invalid idea";
   if (idea.getStackInSlot(0).stackTagCompound.hasKey(Constants.NBT_REFINED) == false)
     return "Please refine your idea";
   if (idea.getStackInSlot(0).stackTagCompound.getInteger(Constants.NBT_REFINED) < 3)
     return "Please refine your idea fully";
   return "All is good";
 }
コード例 #28
0
  @Override
  public void onCrafting(EntityPlayer player, ItemStack output, IInventory craftMatrix) {
    ItemStack itemstack1 = craftMatrix.getStackInSlot(0);

    // Assumption: Only 1 input, will always be decreased by only 1
    if (itemstack1 != null) {
      craftMatrix.decrStackSize(0, 1);
    }

    updateResult();
  }
コード例 #29
0
 /**
  * Attempts to add the itemstack to a random slot in the inventory; failing that, it will add to
  * the first available slot
  *
  * @param numAttempts number of times to attempt random placement
  * @return the number of items remaining in the stack, zero if all were added
  */
 public static int addItemToInventoryAtRandom(
     Random rand, ItemStack stack, IInventory inv, int numAttempts) {
   for (int i = 0; i < numAttempts; ++i) {
     int slot = rand.nextInt(inv.getSizeInventory());
     if (inv.getStackInSlot(slot) == null) {
       inv.setInventorySlotContents(slot, stack);
       return 0;
     }
   }
   return addItemToInventory(stack, inv);
 }
コード例 #30
0
ファイル: FluidHelper.java プロジェクト: asiekierka/Railcraft
 /**
  * We can assume that if null is passed for the container that the container was consumed by the
  * process and we should just remove the input container.
  *
  * @param inv
  * @param inputSlot
  * @param outputSlot
  * @param container
  */
 private static void storeContainer(
     IInventory inv, int inputSlot, int outputSlot, ItemStack container) {
   if (container == null) {
     inv.decrStackSize(inputSlot, 1);
     return;
   }
   ItemStack output = inv.getStackInSlot(outputSlot);
   if (output == null) inv.setInventorySlotContents(outputSlot, container);
   else output.stackSize++;
   inv.decrStackSize(inputSlot, 1);
 }