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