public void setCurrentItem(int par1, int par2, boolean par3, boolean par4)
    {
        boolean var5 = true;
        int var7;

        if (par3)
        {
            var7 = this.getInventorySlotContainItemAndDamage(par1, par2);
        }
        else
        {
            var7 = this.getInventorySlotContainItem(par1);
        }

        if (var7 >= 0 && var7 < 9)
        {
            this.currentItem = var7;
        }
        else
        {
            if (par4 && par1 > 0)
            {
                int var6 = this.getFirstEmptyStack();

                if (var6 >= 0 && var6 < 9)
                {
                    this.currentItem = var6;
                }

                this.func_52006_a(Item.itemsList[par1], par2);
            }
        }
    }