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