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