/** Draw the background layer for the GuiContainer (everything behind the items) */
  protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    RenderHelper.enableGUIStandardItemLighting();
    int var4 = this.mc.renderEngine.getTexture("/gui/allitems.png");
    CreativeTabs var5 = CreativeTabs.creativeTabArray[selectedTabIndex];
    int var6 =
        this.mc.renderEngine.getTexture("/gui/creative_inv/" + var5.getBackgroundImageName());
    CreativeTabs[] var7 = CreativeTabs.creativeTabArray;
    int var8 = var7.length;
    int var9;

    for (var9 = 0; var9 < var8; ++var9) {
      CreativeTabs var10 = var7[var9];
      this.mc.renderEngine.bindTexture(var4);

      if (var10.getTabIndex() != selectedTabIndex) {
        this.renderCreativeTab(var10);
      }
    }

    this.mc.renderEngine.bindTexture(var6);
    this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
    this.searchField.drawTextBox();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    int var11 = this.guiLeft + 175;
    var8 = this.guiTop + 18;
    var9 = var8 + 112;
    this.mc.renderEngine.bindTexture(var4);

    if (var5.shouldHidePlayerInventory()) {
      this.drawTexturedModalRect(
          var11,
          var8 + (int) ((float) (var9 - var8 - 17) * this.currentScroll),
          232 + (this.needsScrollBars() ? 0 : 12),
          0,
          12,
          15);
    }

    this.renderCreativeTab(var5);

    if (var5 == CreativeTabs.tabInventory) {
      GuiInventory.func_74223_a(
          this.mc,
          this.guiLeft + 43,
          this.guiTop + 45,
          20,
          (float) (this.guiLeft + 43 - par2),
          (float) (this.guiTop + 45 - 30 - par3));
    }
  }
  /** Renders passed creative inventory tab into the screen. */
  protected void renderCreativeTab(CreativeTabs par1CreativeTabs) {
    boolean var2 = par1CreativeTabs.getTabIndex() == selectedTabIndex;
    boolean var3 = par1CreativeTabs.isTabInFirstRow();
    int var4 = par1CreativeTabs.getTabColumn();
    int var5 = var4 * 28;
    int var6 = 0;
    int var7 = this.guiLeft + 28 * var4;
    int var8 = this.guiTop;
    byte var9 = 32;

    if (var2) {
      var6 += 32;
    }

    if (var4 == 5) {
      var7 = this.guiLeft + this.xSize - 28;
    } else if (var4 > 0) {
      var7 += var4;
    }

    if (var3) {
      var8 -= 28;
    } else {
      var6 += 64;
      var8 += this.ySize - 4;
    }

    GL11.glDisable(GL11.GL_LIGHTING);
    this.drawTexturedModalRect(var7, var8, var5, var6, 28, var9);
    this.zLevel = 100.0F;
    itemRenderer.zLevel = 100.0F;
    var7 += 6;
    var8 += 8 + (var3 ? 1 : -1);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    ItemStack var10 = par1CreativeTabs.getIconItemStack();
    itemRenderer.renderItemAndEffectIntoGUI(
        this.fontRenderer, this.mc.renderEngine, var10, var7, var8);
    itemRenderer.renderItemOverlayIntoGUI(
        this.fontRenderer, this.mc.renderEngine, var10, var7, var8);
    GL11.glDisable(GL11.GL_LIGHTING);
    itemRenderer.zLevel = 0.0F;
    this.zLevel = 0.0F;
  }
  private void func_74227_b(CreativeTabs par1CreativeTabs) {
    if (par1CreativeTabs == null) {
      return;
    }

    int var2 = selectedTabIndex;
    selectedTabIndex = par1CreativeTabs.getTabIndex();
    ContainerCreative var3 = (ContainerCreative) this.inventorySlots;
    var3.itemList.clear();
    par1CreativeTabs.displayAllReleventItems(var3.itemList);

    if (par1CreativeTabs == CreativeTabs.tabInventory) {
      Container var4 = this.mc.thePlayer.inventoryContainer;

      if (this.field_74236_u == null) {
        this.field_74236_u = var3.inventorySlots;
      }

      var3.inventorySlots = new ArrayList();

      for (int var5 = 0; var5 < var4.inventorySlots.size(); ++var5) {
        SlotCreativeInventory var6 =
            new SlotCreativeInventory(this, (Slot) var4.inventorySlots.get(var5), var5);
        var3.inventorySlots.add(var6);
        int var7;
        int var8;
        int var9;

        if (var5 >= 5 && var5 < 9) {
          var7 = var5 - 5;
          var8 = var7 / 2;
          var9 = var7 % 2;
          var6.xDisplayPosition = 9 + var8 * 54;
          var6.yDisplayPosition = 6 + var9 * 27;
        } else if (var5 >= 0 && var5 < 5) {
          var6.yDisplayPosition = -2000;
          var6.xDisplayPosition = -2000;
        } else if (var5 < var4.inventorySlots.size()) {
          var7 = var5 - 9;
          var8 = var7 % 9;
          var9 = var7 / 9;
          var6.xDisplayPosition = 9 + var8 * 18;

          if (var5 >= 36) {
            var6.yDisplayPosition = 112;
          } else {
            var6.yDisplayPosition = 54 + var9 * 18;
          }
        }
      }

      this.field_74235_v = new Slot(inventory, 0, 173, 112);
      var3.inventorySlots.add(this.field_74235_v);
    } else if (var2 == CreativeTabs.tabInventory.getTabIndex()) {
      var3.inventorySlots = this.field_74236_u;
      this.field_74236_u = null;
    }

    if (this.searchField != null) {
      if (par1CreativeTabs == CreativeTabs.tabAllSearch) {
        this.searchField.setVisible(true);
        this.searchField.setCanLoseFocus(false);
        this.searchField.setFocused(true);
        this.searchField.setText("");
        this.updateCreativeSearch();
      } else {
        this.searchField.setVisible(false);
        this.searchField.setCanLoseFocus(true);
        this.searchField.setFocused(false);
      }
    }

    this.currentScroll = 0.0F;
    var3.scrollTo(0.0F);
  }