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.List; 006 007 public class CreativeTabs 008 { 009 public static final CreativeTabs[] creativeTabArray = new CreativeTabs[12]; 010 public static final CreativeTabs tabBlock = new CreativeTabBlock(0, "buildingBlocks"); 011 public static final CreativeTabs tabDeco = new CreativeTabDeco(1, "decorations"); 012 public static final CreativeTabs tabRedstone = new CreativeTabRedstone(2, "redstone"); 013 public static final CreativeTabs tabTransport = new CreativeTabTransport(3, "transportation"); 014 public static final CreativeTabs tabMisc = new CreativeTabMisc(4, "misc"); 015 public static final CreativeTabs tabAllSearch = (new CreativeTabSearch(5, "search")).setBackgroundImageName("search.png"); 016 public static final CreativeTabs tabFood = new CreativeTabFood(6, "food"); 017 public static final CreativeTabs tabTools = new CreativeTabTools(7, "tools"); 018 public static final CreativeTabs tabCombat = new CreativeTabCombat(8, "combat"); 019 public static final CreativeTabs tabBrewing = new CreativeTabBrewing(9, "brewing"); 020 public static final CreativeTabs tabMaterials = new CreativeTabMaterial(10, "materials"); 021 public static final CreativeTabs tabInventory = (new CreativeTabInventory(11, "inventory")).setBackgroundImageName("survival_inv.png").setNoScrollbar().setNoTitle(); 022 private final int tabIndex; 023 private final String tabLabel; 024 025 /** Texture to use. */ 026 private String backgroundImageName = "list_items.png"; 027 private boolean hasScrollbar = true; 028 029 /** Whether to draw the title in the foreground of the creative GUI */ 030 private boolean drawTitle = true; 031 032 public CreativeTabs(int par1, String par2Str) 033 { 034 this.tabIndex = par1; 035 this.tabLabel = par2Str; 036 creativeTabArray[par1] = this; 037 } 038 039 @SideOnly(Side.CLIENT) 040 public int getTabIndex() 041 { 042 return this.tabIndex; 043 } 044 045 public CreativeTabs setBackgroundImageName(String par1Str) 046 { 047 this.backgroundImageName = par1Str; 048 return this; 049 } 050 051 @SideOnly(Side.CLIENT) 052 public String getTabLabel() 053 { 054 return this.tabLabel; 055 } 056 057 @SideOnly(Side.CLIENT) 058 059 /** 060 * Gets the translated Label. 061 */ 062 public String getTranslatedTabLabel() 063 { 064 return StringTranslate.getInstance().translateKey("itemGroup." + this.getTabLabel()); 065 } 066 067 @SideOnly(Side.CLIENT) 068 public Item getTabIconItem() 069 { 070 return Item.itemsList[this.getTabIconItemIndex()]; 071 } 072 073 @SideOnly(Side.CLIENT) 074 075 /** 076 * the itemID for the item to be displayed on the tab 077 */ 078 public int getTabIconItemIndex() 079 { 080 return 1; 081 } 082 083 @SideOnly(Side.CLIENT) 084 public String getBackgroundImageName() 085 { 086 return this.backgroundImageName; 087 } 088 089 @SideOnly(Side.CLIENT) 090 public boolean drawInForegroundOfTab() 091 { 092 return this.drawTitle; 093 } 094 095 public CreativeTabs setNoTitle() 096 { 097 this.drawTitle = false; 098 return this; 099 } 100 101 @SideOnly(Side.CLIENT) 102 public boolean shouldHidePlayerInventory() 103 { 104 return this.hasScrollbar; 105 } 106 107 public CreativeTabs setNoScrollbar() 108 { 109 this.hasScrollbar = false; 110 return this; 111 } 112 113 @SideOnly(Side.CLIENT) 114 115 /** 116 * returns index % 6 117 */ 118 public int getTabColumn() 119 { 120 return this.tabIndex % 6; 121 } 122 123 @SideOnly(Side.CLIENT) 124 125 /** 126 * returns tabIndex < 6 127 */ 128 public boolean isTabInFirstRow() 129 { 130 return this.tabIndex < 6; 131 } 132 133 @SideOnly(Side.CLIENT) 134 135 /** 136 * only shows items which have tabToDisplayOn == this 137 */ 138 public void displayAllReleventItems(List par1List) 139 { 140 Item[] var2 = Item.itemsList; 141 int var3 = var2.length; 142 143 for (int var4 = 0; var4 < var3; ++var4) 144 { 145 Item var5 = var2[var4]; 146 147 if (var5 != null && var5.getCreativeTab() == this) 148 { 149 var5.getSubItems(var5.shiftedIndex, this, par1List); 150 } 151 } 152 } 153 }