    001package net.minecraft.inventory;
    002
    003import net.minecraft.entity.player.EntityPlayer;
    004import net.minecraft.item.ItemStack;
    005
    006public class InventoryCraftResult implements IInventory
    007{
    008    /** A list of one item containing the result of the crafting formula */
    009    private ItemStack[] stackResult = new ItemStack[1];
    010
    011    /**
    012     * Returns the number of slots in the inventory.
    013     */
    014    public int getSizeInventory()
    015    {
    016        return 1;
    017    }
    018
    019    /**
    020     * Returns the stack in slot i
    021     */
    022    public ItemStack getStackInSlot(int par1)
    023    {
    024        return this.stackResult[0];
    025    }
    026
    027    /**
    028     * Returns the name of the inventory.
    029     */
    030    public String getInvName()
    031    {
    032        return "Result";
    033    }
    034
    035    /**
    036     * If this returns false, the inventory name will be used as an unlocalized name, and translated into the player's
    037     * language. Otherwise it will be used directly.
    038     */
    039    public boolean isInvNameLocalized()
    040    {
    041        return false;
    042    }
    043
    044    /**
    045     * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a
    046     * new stack.
    047     */
    048    public ItemStack decrStackSize(int par1, int par2)
    049    {
    050        if (this.stackResult[0] != null)
    051        {
    052            ItemStack itemstack = this.stackResult[0];
    053            this.stackResult[0] = null;
    054            return itemstack;
    055        }
    056        else
    057        {
    058            return null;
    059        }
    060    }
    061
    062    /**
    063     * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem -
    064     * like when you close a workbench GUI.
    065     */
    066    public ItemStack getStackInSlotOnClosing(int par1)
    067    {
    068        if (this.stackResult[0] != null)
    069        {
    070            ItemStack itemstack = this.stackResult[0];
    071            this.stackResult[0] = null;
    072            return itemstack;
    073        }
    074        else
    075        {
    076            return null;
    077        }
    078    }
    079
    080    /**
    081     * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
    082     */
    083    public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
    084    {
    085        this.stackResult[0] = par2ItemStack;
    086    }
    087
    088    /**
    089     * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't
    090     * this more of a set than a get?*
    091     */
    092    public int getInventoryStackLimit()
    093    {
    094        return 64;
    095    }
    096
    097    /**
    098     * Called when an the contents of an Inventory change, usually
    099     */
    100    public void onInventoryChanged() {}
    101
    102    /**
    103     * Do not make give this method the name canInteractWith because it clashes with Container
    104     */
    105    public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
    106    {
    107        return true;
    108    }
    109
    110    public void openChest() {}
    111
    112    public void closeChest() {}
    113
    114    /**
    115     * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.
    116     */
    117    public boolean isStackValidForSlot(int par1, ItemStack par2ItemStack)
    118    {
    119        return true;
    120    }
    121}