/** Adds the buttons (and other controls) to the screen in question. */
 public void initGui() {
   if (this.mc.playerController.isInCreativeMode()) {
     super.initGui();
     this.controlList.clear();
     Keyboard.enableRepeatEvents(true);
     this.searchField =
         new GuiTextField(
             this.fontRenderer,
             this.guiLeft + 82,
             this.guiTop + 6,
             89,
             this.fontRenderer.FONT_HEIGHT);
     this.searchField.setMaxStringLength(15);
     this.searchField.setEnableBackgroundDrawing(false);
     this.searchField.setVisible(false);
     this.searchField.setTextColor(16777215);
     int var1 = selectedTabIndex;
     selectedTabIndex = -1;
     this.func_74227_b(CreativeTabs.creativeTabArray[var1]);
     this.field_82324_x = new CreativeCrafting(this.mc);
     this.mc.thePlayer.inventoryContainer.addCraftingToCrafters(this.field_82324_x);
     int tabCount = CreativeTabs.creativeTabArray.length;
     if (tabCount > 12) {
       controlList.add(new GuiButton(101, guiLeft, guiTop - 50, 20, 20, "<"));
       controlList.add(new GuiButton(102, guiLeft + xSize - 20, guiTop - 50, 20, 20, ">"));
       tabPage = 0;
       maxPages = ((tabCount - 12) / 10) + 1;
     }
   } else {
     this.mc.displayGuiScreen(new GuiInventory(this.mc.thePlayer));
   }
 }
  /** Handles mouse input. */
  public void handleMouseInput() {
    super.handleMouseInput();
    int var1 = Mouse.getEventDWheel();

    if (var1 != 0 && this.needsScrollBars()) {
      int var2 = ((ContainerCreative) this.inventorySlots).itemList.size() / 9 - 5 + 1;

      if (var1 > 0) {
        var1 = 1;
      }

      if (var1 < 0) {
        var1 = -1;
      }

      this.currentScroll = (float) ((double) this.currentScroll - (double) var1 / (double) var2);

      if (this.currentScroll < 0.0F) {
        this.currentScroll = 0.0F;
      }

      if (this.currentScroll > 1.0F) {
        this.currentScroll = 1.0F;
      }

      ((ContainerCreative) this.inventorySlots).scrollTo(this.currentScroll);
    }
  }
 /** Adds the buttons (and other controls) to the screen in question. */
 public void initGui() {
   if (this.mc.playerController.isInCreativeMode()) {
     super.initGui();
     this.controlList.clear();
     Keyboard.enableRepeatEvents(true);
     this.searchField =
         new GuiTextField(
             this.fontRenderer,
             this.guiLeft + 82,
             this.guiTop + 6,
             89,
             this.fontRenderer.FONT_HEIGHT);
     this.searchField.setMaxStringLength(15);
     this.searchField.setEnableBackgroundDrawing(false);
     this.searchField.setVisible(false);
     this.searchField.setTextColor(16777215);
     int var1 = selectedTabIndex;
     selectedTabIndex = -1;
     this.setCurrentCreativeTab(CreativeTabs.creativeTabArray[var1]);
     this.field_82324_x = new CreativeCrafting(this.mc);
     this.mc.thePlayer.inventoryContainer.addCraftingToCrafters(this.field_82324_x);
   } else {
     this.mc.displayGuiScreen(new GuiInventory(this.mc.thePlayer));
   }
 }
  /** Called when the screen is unloaded. Used to disable keyboard repeat events */
  public void onGuiClosed() {
    super.onGuiClosed();

    if (this.mc.thePlayer != null && this.mc.thePlayer.inventory != null) {
      this.mc.thePlayer.inventoryContainer.removeCraftingFromCrafters(this.field_82324_x);
    }

    Keyboard.enableRepeatEvents(false);
  }
  /** Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e). */
  protected void keyTyped(char par1, int par2) {
    if (selectedTabIndex != CreativeTabs.tabAllSearch.getTabIndex()) {
      if (Keyboard.isKeyDown(this.mc.gameSettings.keyBindChat.keyCode)) {
        this.func_74227_b(CreativeTabs.tabAllSearch);
      } else {
        super.keyTyped(par1, par2);
      }
    } else {
      if (this.field_74234_w) {
        this.field_74234_w = false;
        this.searchField.setText("");
      }

      if (!this.func_82319_a(par2)) {
        if (this.searchField.textboxKeyTyped(par1, par2)) {
          this.updateCreativeSearch();
        } else {
          super.keyTyped(par1, par2);
        }
      }
    }
  }
  /** Called when the mouse is clicked. */
  protected void mouseClicked(int par1, int par2, int par3) {
    if (par3 == 0) {
      int var4 = par1 - this.guiLeft;
      int var5 = par2 - this.guiTop;
      CreativeTabs[] var6 = CreativeTabs.creativeTabArray;
      int var7 = var6.length;

      for (int var8 = 0; var8 < var7; ++var8) {
        CreativeTabs var9 = var6[var8];

        if (var9 != null && func_74232_a(var9, var4, var5)) {
          this.func_74227_b(var9);
          return;
        }
      }
    }

    super.mouseClicked(par1, par2, par3);
  }
  /** Draws the screen and all the components in it. */
  public void drawScreen(int par1, int par2, float par3) {
    boolean var4 = Mouse.isButtonDown(0);
    int var5 = this.guiLeft;
    int var6 = this.guiTop;
    int var7 = var5 + 175;
    int var8 = var6 + 18;
    int var9 = var7 + 14;
    int var10 = var8 + 112;

    if (!this.wasClicking && var4 && par1 >= var7 && par2 >= var8 && par1 < var9 && par2 < var10) {
      this.isScrolling = this.needsScrollBars();
    }

    if (!var4) {
      this.isScrolling = false;
    }

    this.wasClicking = var4;

    if (this.isScrolling) {
      this.currentScroll = ((float) (par2 - var8) - 7.5F) / ((float) (var10 - var8) - 15.0F);

      if (this.currentScroll < 0.0F) {
        this.currentScroll = 0.0F;
      }

      if (this.currentScroll > 1.0F) {
        this.currentScroll = 1.0F;
      }

      ((ContainerCreative) this.inventorySlots).scrollTo(this.currentScroll);
    }

    super.drawScreen(par1, par2, par3);
    CreativeTabs[] var11 = CreativeTabs.creativeTabArray;
    int start = tabPage * 10;
    int var12 = Math.min(var11.length, ((tabPage + 1) * 10) + 2);
    if (tabPage != 0) start += 2;
    boolean rendered = false;

    for (int var13 = start; var13 < var12; ++var13) {
      CreativeTabs var14 = var11[var13];

      if (var14 != null && renderCreativeInventoryHoveringText(var14, par1, par2)) {
        rendered = true;
        break;
      }
    }

    if (!rendered && !renderCreativeInventoryHoveringText(CreativeTabs.tabAllSearch, par1, par2)) {
      renderCreativeInventoryHoveringText(CreativeTabs.tabInventory, par1, par2);
    }

    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)) {
      this.drawCreativeTabHoveringText(
          StringTranslate.getInstance().translateKey("inventory.binSlot"), par1, par2);
    }

    if (maxPages != 0) {
      String page = String.format("%d / %d", tabPage + 1, maxPages + 1);
      int width = fontRenderer.getStringWidth(page);
      GL11.glDisable(GL11.GL_LIGHTING);
      this.zLevel = 300.0F;
      itemRenderer.zLevel = 300.0F;
      fontRenderer.drawString(page, guiLeft + (xSize / 2) - (width / 2), guiTop - 44, -1);
      this.zLevel = 0.0F;
      itemRenderer.zLevel = 0.0F;
    }

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_LIGHTING);
  }
  /** Draws the screen and all the components in it. */
  public void drawScreen(int par1, int par2, float par3) {
    boolean var4 = Mouse.isButtonDown(0);
    int var5 = this.guiLeft;
    int var6 = this.guiTop;
    int var7 = var5 + 175;
    int var8 = var6 + 18;
    int var9 = var7 + 14;
    int var10 = var8 + 112;

    if (!this.wasClicking && var4 && par1 >= var7 && par2 >= var8 && par1 < var9 && par2 < var10) {
      this.isScrolling = this.needsScrollBars();
    }

    if (!var4) {
      this.isScrolling = false;
    }

    this.wasClicking = var4;

    if (this.isScrolling) {
      this.currentScroll = ((float) (par2 - var8) - 7.5F) / ((float) (var10 - var8) - 15.0F);

      if (this.currentScroll < 0.0F) {
        this.currentScroll = 0.0F;
      }

      if (this.currentScroll > 1.0F) {
        this.currentScroll = 1.0F;
      }

      ((ContainerCreative) this.inventorySlots).scrollTo(this.currentScroll);
    }

    super.drawScreen(par1, par2, par3);
    CreativeTabs[] var11 = CreativeTabs.creativeTabArray;
    int var12 = var11.length;

    for (int var13 = 0; var13 < var12; ++var13) {
      CreativeTabs var14 = var11[var13];

      if (this.renderCreativeInventoryHoveringText(var14, par1, par2)) {
        break;
      }
    }

    if (this.field_74235_v != null
        && selectedTabIndex == CreativeTabs.tabInventory.getTabIndex()
        && this.isPointInRegion(
            this.field_74235_v.xDisplayPosition,
            this.field_74235_v.yDisplayPosition,
            16,
            16,
            par1,
            par2)) {
      this.drawCreativeTabHoveringText(
          StringTranslate.getInstance().translateKey("inventory.binSlot"), par1, par2);
    }

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_LIGHTING);
  }