MinecraftForge/MinecraftForge — pull request #488 by immibis (2013-03-28 07:39:30+00:00)
Title: Inventory API

IInventory is designed for GUIs, contains several unnecessary methods (getInvName, getStackInSlotOnClosing, openChest, closeChest, isInvNameLocalized, decrStackSize) and is just hacky.
Although vanilla ISidedInventory grafts on some extra features useful for supporting automation, there are still blocks that cannot be cleanly realized with IInventory, like Factorization barrels.
It also can't support "smart" inventories like most Forestry machines are with Buildcraft.

With this API:
* Machines that insert items into or extract items from inventories (eg pipes, Thermal Expansion machines) should use InventoryAdapters.asCustomInventory to get an IForgeCustomInventory, an object which supports the "insert" and "extract" operations. This way they can work with custom inventories, linear inventories, vanilla sided inventories, Forge sided inventories, vanilla non-sided inventories, and any other inventory types added in the future.
* Machines that need access to specific slots (eg RP2 Sortrons, MiscPeripherals inventory upgrades) should use InventoryAdapters.asLinearInventory to get an IForgeLinearInventory, an object which acts as a list of slots, similar to IInventory. Then they can work with linear inventories, vanilla/Forge sided inventories, non-sided inventories, and other inventory types added in the future.
* ILinearInventory can support features not present on IInventory, such as a per-slot maximum stack size.
* Tiles implementing IInventory can continue to implement IInventory, especially if they have GUIs.
* Tiles which want to use custom input/output behaviour or aren't made of slots (eg barrels) can implement IForgeInventoryTile and IForgeCustomInventory to specify custom behaviour for inserting and extracting items - similar to Buildcraft's ISpecialInventory and ISelectiveInventory.
* Any item filter can be used when extracting items from an inventory. Buildcraft's ISelectiveInventory only allows exact ItemStacks or Item classes to be extracted. For example, you could choose to extract items with a 3 in their ID.
* Pipes could implement IForgeInventoryTile and IForgeCustomInventory to allow other machines to insert items into them as if they were inventories.

Things this API does not support:
* Inventories being accessed on behalf of a player (eg interaction with pipes and vanilla enderchests, or IC2 personal chests)
* GUIs, which still go through IInventory. Changing this would mean writing a new GUI framework.