Flattened ingots.

This commit is contained in:
drcrazy 2018-08-24 13:43:03 +03:00
parent aadc7150f3
commit 1ee9ffb007
18 changed files with 543 additions and 496 deletions

View file

@ -24,69 +24,32 @@
package techreborn.items;
import com.google.common.base.CaseFormat;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Items;
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 ItemIngots extends ItemTR {
public static final String[] types = new String[] { "aluminum", "brass", "bronze", "chrome", "copper", "electrum",
"invar", "iridium", "lead", "nickel", "platinum", "silver", "steel", "tin", "titanium", "tungsten",
"hot_tungstensteel", "tungstensteel", "zinc", "refined_iron", "advanced_alloy", "mixed_metal",
"iridium_alloy" };
public ItemIngots() {
setCreativeTab(TechRebornCreativeTab.instance);
setHasSubtypes(true);
setTranslationKey("techreborn.ingot");
TRRecipeHandler.hideEntry(this);
}
public static ItemStack getIngotByName(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.INGOTS, count, i);
}
}
if (name.equalsIgnoreCase("iron")) {
return new ItemStack(Items.IRON_INGOT);
}
if (name.equalsIgnoreCase("gold")) {
return new ItemStack(Items.GOLD_INGOT);
}
throw new InvalidParameterException("The ingot " + name + " could not be found.");
}
// public static ItemStack getIngotByName(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.INGOTS, count, i);
// }
// }
// if (name.equalsIgnoreCase("iron")) {
// return new ItemStack(Items.IRON_INGOT);
// }
// if (name.equalsIgnoreCase("gold")) {
// return new ItemStack(Items.GOLD_INGOT);
// }
// throw new InvalidParameterException("The ingot " + name + " could not be found.");
// }
//
// public static ItemStack getIngotByName(String name) {
// return getIngotByName(name, 1);
// }
public static ItemStack getIngotByName(String name) {
return getIngotByName(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));
}
}
}