2015-05-04 22:52:08 +02:00
|
|
|
package techreborn.items;
|
|
|
|
|
2016-12-22 01:47:53 +01:00
|
|
|
import com.google.common.base.CaseFormat;
|
2015-05-04 22:52:08 +02:00
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2016-12-11 19:58:20 +01:00
|
|
|
import net.minecraft.util.NonNullList;
|
2015-05-04 22:52:08 +02:00
|
|
|
import techreborn.client.TechRebornCreativeTabMisc;
|
2015-06-07 06:36:37 +02:00
|
|
|
import techreborn.init.ModItems;
|
2015-05-04 22:52:08 +02:00
|
|
|
|
2016-04-30 06:21:28 +02:00
|
|
|
import java.security.InvalidParameterException;
|
|
|
|
|
2016-12-11 19:58:20 +01:00
|
|
|
public class ItemNuggets extends ItemTRNoDestroy {
|
2015-08-09 12:05:32 +02:00
|
|
|
|
2016-04-30 06:21:28 +02:00
|
|
|
public static final String[] types = new String[] { "aluminum", "brass", "bronze", "chrome", "copper", "electrum",
|
2016-10-08 21:46:16 +02:00
|
|
|
"invar", "iridium", "lead", "nickel", "platinum", "silver", "steel", "tin", "titanium", "tungsten",
|
2016-12-11 19:58:20 +01:00
|
|
|
"hot_tungstensteel", "tungstensteel", "zinc", "refined_iron", ModItems.META_PLACEHOLDER, ModItems.META_PLACEHOLDER,
|
2016-10-08 21:46:16 +02:00
|
|
|
ModItems.META_PLACEHOLDER, "iron", "diamond" };
|
2015-08-09 12:05:32 +02:00
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
public ItemNuggets() {
|
2016-03-25 10:47:34 +01:00
|
|
|
setCreativeTab(TechRebornCreativeTabMisc.instance);
|
|
|
|
setHasSubtypes(true);
|
|
|
|
setUnlocalizedName("techreborn.nuggets");
|
|
|
|
}
|
2015-08-09 12:05:32 +02:00
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
public static ItemStack getNuggetByName(String name, int count) {
|
2016-12-22 01:47:53 +01:00
|
|
|
name = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name);
|
2016-10-08 21:46:16 +02:00
|
|
|
for (int i = 0; i < types.length; i++) {
|
|
|
|
if (types[i].equalsIgnoreCase(name)) {
|
2017-01-01 08:29:32 +01:00
|
|
|
return new ItemStack(ModItems.NUGGETS, count, i);
|
2016-03-25 10:47:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new InvalidParameterException("The nugget " + name + " could not be found.");
|
|
|
|
}
|
2015-08-09 12:05:32 +02:00
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
public static ItemStack getNuggetByName(String name) {
|
2016-03-25 10:47:34 +01:00
|
|
|
return getNuggetByName(name, 1);
|
|
|
|
}
|
2015-08-09 12:05:32 +02:00
|
|
|
|
2016-03-25 10:47:34 +01:00
|
|
|
@Override
|
|
|
|
// gets Unlocalized Name depending on meta data
|
2016-10-08 21:46:16 +02:00
|
|
|
public String getUnlocalizedName(ItemStack itemStack) {
|
2016-03-25 10:47:34 +01:00
|
|
|
int meta = itemStack.getItemDamage();
|
2016-10-08 21:46:16 +02:00
|
|
|
if (meta < 0 || meta >= types.length) {
|
2016-03-25 10:47:34 +01:00
|
|
|
meta = 0;
|
|
|
|
}
|
2015-08-09 12:05:32 +02:00
|
|
|
|
2016-03-25 10:47:34 +01:00
|
|
|
return super.getUnlocalizedName() + "." + types[meta];
|
|
|
|
}
|
2015-08-09 12:05:32 +02:00
|
|
|
|
2016-03-25 10:47:34 +01:00
|
|
|
// Adds Dusts SubItems To Creative Tab
|
2016-12-11 19:58:20 +01:00
|
|
|
@Override
|
|
|
|
public void getSubItems(Item item, CreativeTabs creativeTabs, NonNullList list) {
|
2016-10-08 21:46:16 +02:00
|
|
|
for (int meta = 0; meta < types.length; ++meta) {
|
|
|
|
if (!types[meta].equals(ModItems.META_PLACEHOLDER)) {
|
2016-05-30 14:18:43 +02:00
|
|
|
list.add(new ItemStack(item, 1, meta));
|
|
|
|
}
|
2016-03-25 10:47:34 +01:00
|
|
|
}
|
|
|
|
}
|
2015-05-04 22:52:08 +02:00
|
|
|
|
|
|
|
}
|