    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import java.util.ArrayList;
    006    import java.util.Iterator;
    007    import java.util.List;
    008    import org.lwjgl.input.Keyboard;
    009    import org.lwjgl.input.Mouse;
    010    import org.lwjgl.opengl.GL11;
    011    import org.lwjgl.opengl.GL12;
    012
    013    @SideOnly(Side.CLIENT)
    014    public class GuiContainerCreative extends InventoryEffectRenderer
    015    {
    016        private static InventoryBasic inventory = new InventoryBasic("tmp", 45);
    017
    018        /** Currently selected creative inventory tab index. */
    019        private static int selectedTabIndex = CreativeTabs.tabBlock.getTabIndex();
    020
    021        /** Amount scrolled in Creative mode inventory (0 = top, 1 = bottom) */
    022        private float currentScroll = 0.0F;
    023
    024        /** True if the scrollbar is being dragged */
    025        private boolean isScrolling = false;
    026
    027        /**
    028         * True if the left mouse button was held down last time drawScreen was called.
    029         */
    030        private boolean wasClicking;
    031        private GuiTextField searchField;
    032        private List field_74236_u;
    033        private Slot field_74235_v = null;
    034        private boolean field_74234_w = false;
    035        private int tabPage = 0;
    036        private int maxPages = 0;
    037
    038        public GuiContainerCreative(EntityPlayer par1EntityPlayer)
    039        {
    040            super(new ContainerCreative(par1EntityPlayer));
    041            par1EntityPlayer.craftingInventory = this.inventorySlots;
    042            this.allowUserInput = true;
    043            par1EntityPlayer.addStat(AchievementList.openInventory, 1);
    044            this.ySize = 136;
    045            this.xSize = 195;
    046        }
    047
    048        /**
    049         * Called from the main game loop to update the screen.
    050         */
    051        public void updateScreen()
    052        {
    053            if (!this.mc.playerController.isInCreativeMode())
    054            {
    055                this.mc.displayGuiScreen(new GuiInventory(this.mc.thePlayer));
    056            }
    057        }
    058
    059        protected void handleMouseClick(Slot par1Slot, int par2, int par3, boolean par4)
    060        {
    061            this.field_74234_w = true;
    062            ItemStack var6;
    063            InventoryPlayer var9;
    064
    065            if (par1Slot != null)
    066            {
    067                int var5;
    068
    069                if (par1Slot == this.field_74235_v && par4)
    070                {
    071                    for (var5 = 0; var5 < this.mc.thePlayer.inventorySlots.getInventory().size(); ++var5)
    072                    {
    073                        this.mc.playerController.sendSlotPacket((ItemStack)null, var5);
    074                    }
    075                }
    076                else
    077                {
    078                    ItemStack var7;
    079
    080                    if (selectedTabIndex == CreativeTabs.tabInventory.getTabIndex())
    081                    {
    082                        if (par1Slot == this.field_74235_v)
    083                        {
    084                            this.mc.thePlayer.inventory.setItemStack((ItemStack)null);
    085                        }
    086                        else
    087                        {
    088                            var5 = SlotCreativeInventory.func_75240_a((SlotCreativeInventory)par1Slot).slotNumber;
    089                            var6 = this.mc.thePlayer.inventorySlots.getSlot(var5).getStack();
    090
    091                            if (par4 && (var6 == null || !(var6.getItem() instanceof ItemArmor)))
    092                            {
    093                                this.mc.playerController.sendSlotPacket((ItemStack)null, var5);
    094                            }
    095                            else
    096                            {
    097                                this.mc.thePlayer.inventorySlots.slotClick(var5, par3, par4, this.mc.thePlayer);
    098                                var7 = this.mc.thePlayer.inventorySlots.getSlot(var5).getStack();
    099                                this.mc.playerController.sendSlotPacket(var7, var5);
    100                            }
    101                        }
    102                    }
    103                    else if (par1Slot.inventory == inventory)
    104                    {
    105                        var9 = this.mc.thePlayer.inventory;
    106                        var6 = var9.getItemStack();
    107                        var7 = par1Slot.getStack();
    108
    109                        if (var6 != null && var7 != null && var6.isItemEqual(var7))
    110                        {
    111                            if (par3 == 0)
    112                            {
    113                                if (par4)
    114                                {
    115                                    var6.stackSize = var6.getMaxStackSize();
    116                                }
    117                                else if (var6.stackSize < var6.getMaxStackSize())
    118                                {
    119                                    ++var6.stackSize;
    120                                }
    121                            }
    122                            else if (var6.stackSize <= 1)
    123                            {
    124                                var9.setItemStack((ItemStack)null);
    125                            }
    126                            else
    127                            {
    128                                --var6.stackSize;
    129                            }
    130                        }
    131                        else if (var7 != null && var6 == null)
    132                        {
    133                            boolean var8 = false;
    134
    135                            if (!var8)
    136                            {
    137                                var9.setItemStack(ItemStack.copyItemStack(var7));
    138                                var6 = var9.getItemStack();
    139
    140                                if (par4)
    141                                {
    142                                    var6.stackSize = var6.getMaxStackSize();
    143                                }
    144                            }
    145                        }
    146                        else
    147                        {
    148                            var9.setItemStack((ItemStack)null);
    149                        }
    150                    }
    151                    else
    152                    {
    153                        this.inventorySlots.slotClick(par1Slot.slotNumber, par3, par4, this.mc.thePlayer);
    154                        ItemStack var10 = this.inventorySlots.getSlot(par1Slot.slotNumber).getStack();
    155                        this.mc.playerController.sendSlotPacket(var10, par1Slot.slotNumber - this.inventorySlots.inventorySlots.size() + 9 + 36);
    156                    }
    157                }
    158            }
    159            else
    160            {
    161                var9 = this.mc.thePlayer.inventory;
    162
    163                if (var9.getItemStack() != null)
    164                {
    165                    if (par3 == 0)
    166                    {
    167                        this.mc.thePlayer.dropPlayerItem(var9.getItemStack());
    168                        this.mc.playerController.func_78752_a(var9.getItemStack());
    169                        var9.setItemStack((ItemStack)null);
    170                    }
    171
    172                    if (par3 == 1)
    173                    {
    174                        var6 = var9.getItemStack().splitStack(1);
    175                        this.mc.thePlayer.dropPlayerItem(var6);
    176                        this.mc.playerController.func_78752_a(var6);
    177
    178                        if (var9.getItemStack().stackSize == 0)
    179                        {
    180                            var9.setItemStack((ItemStack)null);
    181                        }
    182                    }
    183                }
    184            }
    185        }
    186
    187        /**
    188         * Adds the buttons (and other controls) to the screen in question.
    189         */
    190        public void initGui()
    191        {
    192            if (this.mc.playerController.isInCreativeMode())
    193            {
    194                super.initGui();
    195                this.controlList.clear();
    196                Keyboard.enableRepeatEvents(true);
    197                this.searchField = new GuiTextField(this.fontRenderer, this.guiLeft + 82, this.guiTop + 6, 89, this.fontRenderer.FONT_HEIGHT);
    198                this.searchField.setMaxStringLength(15);
    199                this.searchField.setEnableBackgroundDrawing(false);
    200                this.searchField.setVisible(false);
    201                this.searchField.setTextColor(16777215);
    202                int var1 = selectedTabIndex;
    203                selectedTabIndex = -1;
    204                this.func_74227_b(CreativeTabs.creativeTabArray[var1]);
    205                int tabCount = CreativeTabs.creativeTabArray.length;
    206                if (tabCount > 12)
    207                {
    208                    controlList.add(new GuiButton(101, guiLeft,              guiTop - 50, 20, 20, "<"));
    209                    controlList.add(new GuiButton(102, guiLeft + xSize - 20, guiTop - 50, 20, 20, ">"));
    210                    tabPage = 0;
    211                    maxPages = ((tabCount - 12) / 10) + 1;
    212                }
    213            }
    214            else
    215            {
    216                this.mc.displayGuiScreen(new GuiInventory(this.mc.thePlayer));
    217            }
    218        }
    219
    220        /**
    221         * Called when the screen is unloaded. Used to disable keyboard repeat events
    222         */
    223        public void onGuiClosed()
    224        {
    225            super.onGuiClosed();
    226            Keyboard.enableRepeatEvents(false);
    227        }
    228
    229        /**
    230         * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
    231         */
    232        protected void keyTyped(char par1, int par2)
    233        {
    234            if (selectedTabIndex != CreativeTabs.tabAllSearch.getTabIndex())
    235            {
    236                if (Keyboard.isKeyDown(this.mc.gameSettings.keyBindChat.keyCode))
    237                {
    238                    this.func_74227_b(CreativeTabs.tabAllSearch);
    239                }
    240                else
    241                {
    242                    super.keyTyped(par1, par2);
    243                }
    244            }
    245            else
    246            {
    247                if (this.field_74234_w)
    248                {
    249                    this.field_74234_w = false;
    250                    this.searchField.setText("");
    251                }
    252
    253                if (this.searchField.textboxKeyTyped(par1, par2))
    254                {
    255                    this.func_74228_j();
    256                }
    257                else
    258                {
    259                    super.keyTyped(par1, par2);
    260                }
    261            }
    262        }
    263
    264        private void func_74228_j()
    265        {
    266            ContainerCreative var1 = (ContainerCreative)this.inventorySlots;
    267            var1.itemList.clear();
    268            Item[] var2 = Item.itemsList;
    269            int var3 = var2.length;
    270
    271            for (int var4 = 0; var4 < var3; ++var4)
    272            {
    273                Item var5 = var2[var4];
    274
    275                if (var5 != null && var5.getCreativeTab() != null)
    276                {
    277                    var5.getSubItems(var5.shiftedIndex, (CreativeTabs)null, var1.itemList);
    278                }
    279            }
    280
    281            Iterator var8 = var1.itemList.iterator();
    282            String var9 = this.searchField.getText().toLowerCase();
    283
    284            while (var8.hasNext())
    285            {
    286                ItemStack var10 = (ItemStack)var8.next();
    287                boolean var11 = false;
    288                Iterator var6 = var10.getItemNameandInformation().iterator();
    289
    290                while (true)
    291                {
    292                    if (var6.hasNext())
    293                    {
    294                        String var7 = (String)var6.next();
    295
    296                        if (!var7.toLowerCase().contains(var9))
    297                        {
    298                            continue;
    299                        }
    300
    301                        var11 = true;
    302                    }
    303
    304                    if (!var11)
    305                    {
    306                        var8.remove();
    307                    }
    308
    309                    break;
    310                }
    311            }
    312
    313            this.currentScroll = 0.0F;
    314            var1.scrollTo(0.0F);
    315        }
    316
    317        /**
    318         * Draw the foreground layer for the GuiContainer (everything in front of the items)
    319         */
    320        protected void drawGuiContainerForegroundLayer()
    321        {
    322            CreativeTabs var1 = CreativeTabs.creativeTabArray[selectedTabIndex];
    323
    324            if (var1 != null && var1.drawInForegroundOfTab())
    325            {
    326                this.fontRenderer.drawString(var1.getTranslatedTabLabel(), 8, 6, 4210752);
    327            }
    328        }
    329
    330        /**
    331         * Called when the mouse is clicked.
    332         */
    333        protected void mouseClicked(int par1, int par2, int par3)
    334        {
    335            if (par3 == 0)
    336            {
    337                int var4 = par1 - this.guiLeft;
    338                int var5 = par2 - this.guiTop;
    339                CreativeTabs[] var6 = CreativeTabs.creativeTabArray;
    340                int var7 = var6.length;
    341
    342                for (int var8 = 0; var8 < var7; ++var8)
    343                {
    344                    CreativeTabs var9 = var6[var8];
    345
    346                    if (var9 != null && func_74232_a(var9, var4, var5))
    347                    {
    348                        this.func_74227_b(var9);
    349                        return;
    350                    }
    351                }
    352            }
    353
    354            super.mouseClicked(par1, par2, par3);
    355        }
    356
    357        /**
    358         * returns (if you are not on the inventoryTab) and (the flag isn't set) and( you have more than 1 page of items)
    359         */
    360        private boolean needsScrollBars()
    361        {
    362            if (CreativeTabs.creativeTabArray[selectedTabIndex] == null) return false;
    363            return selectedTabIndex != CreativeTabs.tabInventory.getTabIndex() && CreativeTabs.creativeTabArray[selectedTabIndex].shouldHidePlayerInventory() && ((ContainerCreative)this.inventorySlots).hasMoreThan1PageOfItemsInList();
    364        }
    365
    366        private void func_74227_b(CreativeTabs par1CreativeTabs)
    367        {
    368            if (par1CreativeTabs == null)
    369            {
    370                return;
    371            }
    372
    373            int var2 = selectedTabIndex;
    374            selectedTabIndex = par1CreativeTabs.getTabIndex();
    375            ContainerCreative var3 = (ContainerCreative)this.inventorySlots;
    376            var3.itemList.clear();
    377            par1CreativeTabs.displayAllReleventItems(var3.itemList);
    378
    379            if (par1CreativeTabs == CreativeTabs.tabInventory)
    380            {
    381                Container var4 = this.mc.thePlayer.inventorySlots;
    382
    383                if (this.field_74236_u == null)
    384                {
    385                    this.field_74236_u = var3.inventorySlots;
    386                }
    387
    388                var3.inventorySlots = new ArrayList();
    389
    390                for (int var5 = 0; var5 < var4.inventorySlots.size(); ++var5)
    391                {
    392                    SlotCreativeInventory var6 = new SlotCreativeInventory(this, (Slot)var4.inventorySlots.get(var5), var5);
    393                    var3.inventorySlots.add(var6);
    394                    int var7;
    395                    int var8;
    396                    int var9;
    397
    398                    if (var5 >= 5 && var5 < 9)
    399                    {
    400                        var7 = var5 - 5;
    401                        var8 = var7 / 2;
    402                        var9 = var7 % 2;
    403                        var6.xDisplayPosition = 9 + var8 * 54;
    404                        var6.yDisplayPosition = 6 + var9 * 27;
    405                    }
    406                    else if (var5 >= 0 && var5 < 5)
    407                    {
    408                        var6.yDisplayPosition = -2000;
    409                        var6.xDisplayPosition = -2000;
    410                    }
    411                    else if (var5 < var4.inventorySlots.size())
    412                    {
    413                        var7 = var5 - 9;
    414                        var8 = var7 % 9;
    415                        var9 = var7 / 9;
    416                        var6.xDisplayPosition = 9 + var8 * 18;
    417
    418                        if (var5 >= 36)
    419                        {
    420                            var6.yDisplayPosition = 112;
    421                        }
    422                        else
    423                        {
    424                            var6.yDisplayPosition = 54 + var9 * 18;
    425                        }
    426                    }
    427                }
    428
    429                this.field_74235_v = new Slot(inventory, 0, 173, 112);
    430                var3.inventorySlots.add(this.field_74235_v);
    431            }
    432            else if (var2 == CreativeTabs.tabInventory.getTabIndex())
    433            {
    434                var3.inventorySlots = this.field_74236_u;
    435                this.field_74236_u = null;
    436            }
    437
    438            if (this.searchField != null)
    439            {
    440                if (par1CreativeTabs == CreativeTabs.tabAllSearch)
    441                {
    442                    this.searchField.setVisible(true);
    443                    this.searchField.setCanLoseFocus(false);
    444                    this.searchField.setFocused(true);
    445                    this.searchField.setText("");
    446                    this.func_74228_j();
    447                }
    448                else
    449                {
    450                    this.searchField.setVisible(false);
    451                    this.searchField.setCanLoseFocus(true);
    452                    this.searchField.setFocused(false);
    453                }
    454            }
    455
    456            this.currentScroll = 0.0F;
    457            var3.scrollTo(0.0F);
    458        }
    459
    460        /**
    461         * Handles mouse input.
    462         */
    463        public void handleMouseInput()
    464        {
    465            super.handleMouseInput();
    466            int var1 = Mouse.getEventDWheel();
    467
    468            if (var1 != 0 && this.needsScrollBars())
    469            {
    470                int var2 = ((ContainerCreative)this.inventorySlots).itemList.size() / 9 - 5 + 1;
    471
    472                if (var1 > 0)
    473                {
    474                    var1 = 1;
    475                }
    476
    477                if (var1 < 0)
    478                {
    479                    var1 = -1;
    480                }
    481
    482                this.currentScroll = (float)((double)this.currentScroll - (double)var1 / (double)var2);
    483
    484                if (this.currentScroll < 0.0F)
    485                {
    486                    this.currentScroll = 0.0F;
    487                }
    488
    489                if (this.currentScroll > 1.0F)
    490                {
    491                    this.currentScroll = 1.0F;
    492                }
    493
    494                ((ContainerCreative)this.inventorySlots).scrollTo(this.currentScroll);
    495            }
    496        }
    497
    498        /**
    499         * Draws the screen and all the components in it.
    500         */
    501        public void drawScreen(int par1, int par2, float par3)
    502        {
    503            boolean var4 = Mouse.isButtonDown(0);
    504            int var5 = this.guiLeft;
    505            int var6 = this.guiTop;
    506            int var7 = var5 + 175;
    507            int var8 = var6 + 18;
    508            int var9 = var7 + 14;
    509            int var10 = var8 + 112;
    510
    511            if (!this.wasClicking && var4 && par1 >= var7 && par2 >= var8 && par1 < var9 && par2 < var10)
    512            {
    513                this.isScrolling = this.needsScrollBars();
    514            }
    515
    516            if (!var4)
    517            {
    518                this.isScrolling = false;
    519            }
    520
    521            this.wasClicking = var4;
    522
    523            if (this.isScrolling)
    524            {
    525                this.currentScroll = ((float)(par2 - var8) - 7.5F) / ((float)(var10 - var8) - 15.0F);
    526
    527                if (this.currentScroll < 0.0F)
    528                {
    529                    this.currentScroll = 0.0F;
    530                }
    531
    532                if (this.currentScroll > 1.0F)
    533                {
    534                    this.currentScroll = 1.0F;
    535                }
    536
    537                ((ContainerCreative)this.inventorySlots).scrollTo(this.currentScroll);
    538            }
    539
    540            super.drawScreen(par1, par2, par3);
    541            CreativeTabs[] var11 = CreativeTabs.creativeTabArray;
    542            int start = tabPage * 10;
    543            int var12 = Math.min(var11.length, ((tabPage + 1) * 10) + 2);
    544            if (tabPage != 0) start += 2;
    545            boolean rendered = false;
    546
    547            for (int var13 = start; var13 < var12; ++var13)
    548            {
    549                CreativeTabs var14 = var11[var13];
    550
    551                if (var14 != null && renderCreativeInventoryHoveringText(var14, par1, par2))
    552                {
    553                    rendered = true;
    554                    break;
    555                }
    556            }
    557
    558            if (!rendered && !renderCreativeInventoryHoveringText(CreativeTabs.tabAllSearch, par1, par2))
    559            {
    560                renderCreativeInventoryHoveringText(CreativeTabs.tabInventory, par1, par2);
    561            }
    562
    563            if (this.field_74235_v != null && selectedTabIndex == CreativeTabs.tabInventory.getTabIndex() && this.func_74188_c(this.field_74235_v.xDisplayPosition, this.field_74235_v.yDisplayPosition, 16, 16, par1, par2))
    564            {
    565                this.drawCreativeTabHoveringText(StringTranslate.getInstance().translateKey("inventory.binSlot"), par1, par2);
    566            }
    567
    568            if (maxPages != 0)
    569            {
    570                String page = String.format("%d / %d", tabPage + 1, maxPages + 1);
    571                int width = fontRenderer.getStringWidth(page);
    572                GL11.glDisable(GL11.GL_LIGHTING);
    573                this.zLevel = 300.0F;
    574                itemRenderer.zLevel = 300.0F;
    575                fontRenderer.drawString(page, guiLeft + (xSize / 2) - (width / 2), guiTop - 44, -1);
    576                this.zLevel = 0.0F;
    577                itemRenderer.zLevel = 0.0F;
    578            }
    579
    580            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    581            GL11.glDisable(GL11.GL_LIGHTING);
    582        }
    583
    584        /**
    585         * Draw the background layer for the GuiContainer (everything behind the items)
    586         */
    587        protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
    588        {
    589            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    590            RenderHelper.enableGUIStandardItemLighting();
    591            int var4 = this.mc.renderEngine.getTexture("/gui/allitems.png");
    592            CreativeTabs var5 = CreativeTabs.creativeTabArray[selectedTabIndex];
    593            int var6 = this.mc.renderEngine.getTexture("/gui/creative_inv/" + var5.getBackgroundImageName());
    594            CreativeTabs[] var7 = CreativeTabs.creativeTabArray;
    595            int var8 = var7.length;
    596            int var9;
    597
    598            int start = tabPage * 10;
    599            var8 = Math.min(var7.length, ((tabPage + 1) * 10 + 2));
    600            if (tabPage != 0) start += 2;
    601
    602            for (var9 = start; var9 < var8; ++var9)
    603            {
    604                CreativeTabs var10 = var7[var9];
    605                this.mc.renderEngine.bindTexture(var4);
    606
    607                if (var10 != null && var10.getTabIndex() != selectedTabIndex)
    608                {
    609                    this.renderCreativeTab(var10);
    610                }
    611            }
    612
    613            if (tabPage != 0)
    614            {
    615                if (var5 != CreativeTabs.tabAllSearch)
    616                {
    617                    mc.renderEngine.bindTexture(var4);
    618                    renderCreativeTab(CreativeTabs.tabAllSearch);
    619                }
    620                if (var5 != CreativeTabs.tabInventory)
    621                {
    622                    mc.renderEngine.bindTexture(var4);
    623                    renderCreativeTab(CreativeTabs.tabInventory);
    624                }
    625            }
    626
    627            this.mc.renderEngine.bindTexture(var6);
    628            this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
    629            this.searchField.drawTextBox();
    630            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    631            int var11 = this.guiLeft + 175;
    632            var8 = this.guiTop + 18;
    633            var9 = var8 + 112;
    634            this.mc.renderEngine.bindTexture(var4);
    635
    636            if (var5 == null || var5.getTabPage() != tabPage)
    637            {
    638                if (var5 != CreativeTabs.tabAllSearch && var5 != CreativeTabs.tabInventory)
    639                {
    640                    return;
    641                }
    642            }
    643
    644            if (var5.shouldHidePlayerInventory())
    645            {
    646                this.drawTexturedModalRect(var11, var8 + (int)((float)(var9 - var8 - 17) * this.currentScroll), 232 + (this.needsScrollBars() ? 0 : 12), 0, 12, 15);
    647            }
    648
    649            this.renderCreativeTab(var5);
    650
    651            if (var5 == CreativeTabs.tabInventory)
    652            {
    653                GuiInventory.func_74223_a(this.mc, this.guiLeft + 43, this.guiTop + 45, 20, (float)(this.guiLeft + 43 - par2), (float)(this.guiTop + 45 - 30 - par3));
    654            }
    655        }
    656
    657        protected boolean func_74232_a(CreativeTabs par1CreativeTabs, int par2, int par3)
    658        {
    659            if (par1CreativeTabs.getTabPage() != tabPage)
    660            {
    661                if (par1CreativeTabs != CreativeTabs.tabAllSearch &&
    662                    par1CreativeTabs != CreativeTabs.tabInventory)
    663                {
    664                    return false;
    665                }
    666            }
    667
    668            int var4 = par1CreativeTabs.getTabColumn();
    669            int var5 = 28 * var4;
    670            byte var6 = 0;
    671
    672            if (var4 == 5)
    673            {
    674                var5 = this.xSize - 28 + 2;
    675            }
    676            else if (var4 > 0)
    677            {
    678                var5 += var4;
    679            }
    680
    681            int var7;
    682
    683            if (par1CreativeTabs.isTabInFirstRow())
    684            {
    685                var7 = var6 - 32;
    686            }
    687            else
    688            {
    689                var7 = var6 + this.ySize;
    690            }
    691
    692            return par2 >= var5 && par2 <= var5 + 28 && par3 >= var7 && par3 <= var7 + 32;
    693        }
    694
    695        /**
    696         * Renders the creative inventory hovering text if mouse is over it. Returns true if did render or false otherwise.
    697         * Params: current creative tab to be checked, current mouse x position, current mouse y position.
    698         */
    699        protected boolean renderCreativeInventoryHoveringText(CreativeTabs par1CreativeTabs, int par2, int par3)
    700        {
    701            int var4 = par1CreativeTabs.getTabColumn();
    702            int var5 = 28 * var4;
    703            byte var6 = 0;
    704
    705            if (var4 == 5)
    706            {
    707                var5 = this.xSize - 28 + 2;
    708            }
    709            else if (var4 > 0)
    710            {
    711                var5 += var4;
    712            }
    713
    714            int var7;
    715
    716            if (par1CreativeTabs.isTabInFirstRow())
    717            {
    718                var7 = var6 - 32;
    719            }
    720            else
    721            {
    722                var7 = var6 + this.ySize;
    723            }
    724
    725            if (this.func_74188_c(var5 + 3, var7 + 3, 23, 27, par2, par3))
    726            {
    727                this.drawCreativeTabHoveringText(par1CreativeTabs.getTranslatedTabLabel(), par2, par3);
    728                return true;
    729            }
    730            else
    731            {
    732                return false;
    733            }
    734        }
    735
    736        /**
    737         * Renders passed creative inventory tab into the screen.
    738         */
    739        protected void renderCreativeTab(CreativeTabs par1CreativeTabs)
    740        {
    741            boolean var2 = par1CreativeTabs.getTabIndex() == selectedTabIndex;
    742            boolean var3 = par1CreativeTabs.isTabInFirstRow();
    743            int var4 = par1CreativeTabs.getTabColumn();
    744            int var5 = var4 * 28;
    745            int var6 = 0;
    746            int var7 = this.guiLeft + 28 * var4;
    747            int var8 = this.guiTop;
    748            byte var9 = 32;
    749
    750            if (var2)
    751            {
    752                var6 += 32;
    753            }
    754
    755            if (var4 == 5)
    756            {
    757                var7 = this.guiLeft + this.xSize - 28;
    758            }
    759            else if (var4 > 0)
    760            {
    761                var7 += var4;
    762            }
    763
    764            if (var3)
    765            {
    766                var8 -= 28;
    767            }
    768            else
    769            {
    770                var6 += 64;
    771                var8 += this.ySize - 4;
    772            }
    773
    774            GL11.glDisable(GL11.GL_LIGHTING);
    775            this.drawTexturedModalRect(var7, var8, var5, var6, 28, var9);
    776            this.zLevel = 100.0F;
    777            itemRenderer.zLevel = 100.0F;
    778            var7 += 6;
    779            var8 += 8 + (var3 ? 1 : -1);
    780            GL11.glEnable(GL11.GL_LIGHTING);
    781            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    782            ItemStack var10 = par1CreativeTabs.getIconItemStack();
    783            itemRenderer.renderItemIntoGUI(this.fontRenderer, this.mc.renderEngine, var10, var7, var8);
    784            itemRenderer.renderItemOverlayIntoGUI(this.fontRenderer, this.mc.renderEngine, var10, var7, var8);
    785            GL11.glDisable(GL11.GL_LIGHTING);
    786            itemRenderer.zLevel = 0.0F;
    787            this.zLevel = 0.0F;
    788        }
    789
    790        /**
    791         * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
    792         */
    793        protected void actionPerformed(GuiButton par1GuiButton)
    794        {
    795            if (par1GuiButton.id == 0)
    796            {
    797                this.mc.displayGuiScreen(new GuiAchievements(this.mc.statFileWriter));
    798            }
    799
    800            if (par1GuiButton.id == 1)
    801            {
    802                this.mc.displayGuiScreen(new GuiStats(this, this.mc.statFileWriter));
    803            }
    804
    805            if (par1GuiButton.id == 101)
    806            {
    807                tabPage = Math.max(tabPage - 1, 0);
    808            }
    809            else if (par1GuiButton.id == 102)
    810            {
    811                tabPage = Math.min(tabPage + 1, maxPages);
    812            }
    813        }
    814
    815        public int func_74230_h()
    816        {
    817            return selectedTabIndex;
    818        }
    819
    820        /**
    821         * Returns the creative inventory
    822         */
    823        static InventoryBasic getInventory()
    824        {
    825            return inventory;
    826        }
    827    }