Gems are flattened
This commit is contained in:
parent
2939ee02a3
commit
aadc7150f3
16 changed files with 188 additions and 116 deletions
|
@ -24,61 +24,26 @@
|
|||
|
||||
package techreborn.items;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import techreborn.events.TRRecipeHandler;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.utils.TechRebornCreativeTab;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
|
||||
public class ItemGems extends ItemTR {
|
||||
|
||||
public static final String[] types = new String[] { "ruby", "sapphire", "peridot", "red_garnet", "yellow_garnet" };
|
||||
|
||||
public ItemGems() {
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
setTranslationKey("techreborn.gem");
|
||||
setHasSubtypes(true);
|
||||
TRRecipeHandler.hideEntry(this);
|
||||
}
|
||||
|
||||
public static ItemStack getGemByName(String name, int count) {
|
||||
name = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name);
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
if (types[i].equalsIgnoreCase(name)) {
|
||||
return new ItemStack(ModItems.GEMS, count, i);
|
||||
}
|
||||
}
|
||||
throw new InvalidParameterException("The gem " + name + " could not be found.");
|
||||
}
|
||||
|
||||
public static ItemStack getGemByName(String name) {
|
||||
return getGemByName(name, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
// gets Unlocalized Name depending on meta data
|
||||
public String getTranslationKey(ItemStack itemStack) {
|
||||
int meta = itemStack.getItemDamage();
|
||||
if (meta < 0 || meta >= types.length) {
|
||||
meta = 0;
|
||||
}
|
||||
|
||||
return super.getTranslationKey() + "." + types[meta];
|
||||
}
|
||||
|
||||
// Adds Dusts SubItems To Creative Tab
|
||||
@Override
|
||||
public void getSubItems(CreativeTabs creativeTabs, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTabs)) {
|
||||
return;
|
||||
}
|
||||
for (int meta = 0; meta < types.length; ++meta) {
|
||||
list.add(new ItemStack(this, 1, meta));
|
||||
}
|
||||
}
|
||||
// public static ItemStack getGemByName(String name, int count) {
|
||||
// name = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name);
|
||||
// for (int i = 0; i < types.length; i++) {
|
||||
// if (types[i].equalsIgnoreCase(name)) {
|
||||
// return new ItemStack(ModItems.GEMS, count, i);
|
||||
// }
|
||||
// }
|
||||
// throw new InvalidParameterException("The gem " + name + " could not be found.");
|
||||
// }
|
||||
//
|
||||
// public static ItemStack getGemByName(String name) {
|
||||
// return getGemByName(name, 1);
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue