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