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