TechReborn/src/main/java/techreborn/items/ItemDustsSmall.java

81 lines
2.8 KiB
Java
Raw Normal View History

2015-04-17 00:27:25 +02:00
package techreborn.items;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
2016-05-13 12:07:56 +02:00
import reborncore.common.util.StringUtils;
import techreborn.client.TechRebornCreativeTabMisc;
import techreborn.init.ModItems;
2015-11-24 23:58:18 +01:00
import techreborn.lib.ModInfo;
2015-04-17 00:27:25 +02:00
import java.security.InvalidParameterException;
import java.util.List;
2016-10-08 21:46:16 +02:00
public class ItemDustsSmall extends ItemTextureBase {
2016-03-25 10:47:34 +01:00
public static final String[] types = new String[] { "almandine", "aluminum", "andradite", "ashes", "basalt",
2016-10-08 21:46:16 +02:00
"bauxite", "brass", "bronze", "calcite", "charcoal", "chrome", "cinnabar", "clay", "coal", "copper",
"darkAshes", "diamond", "electrum", "emerald", "enderEye", "enderPearl", "endstone", "flint", "galena",
"gold", "grossular", "invar", "iron", "lazurite", "lead", "magnesium", "manganese", "marble", "netherrack",
"nickel", "obsidian", "peridot", "phosphorous", "platinum", "pyrite", "pyrope", "redGarnet", ModItems.META_PLACEHOLDER,
"ruby", "saltpeter", "sapphire", "sawDust", "silver", "sodalite", "spessartine", "sphalerite", "steel",
"sulfur", "tin", "titanium", "tungsten", "uvarovite", ModItems.META_PLACEHOLDER, "yellowGarnet", "zinc",
"olivine", "redstone", "glowstone", "andesite", "diorite", "granite" };
2016-03-25 10:47:34 +01:00
2016-10-08 21:46:16 +02:00
public ItemDustsSmall() {
2016-03-25 10:47:34 +01:00
setUnlocalizedName("techreborn.dustsmall");
setHasSubtypes(true);
setCreativeTab(TechRebornCreativeTabMisc.instance);
}
2016-10-08 21:46:16 +02:00
public static ItemStack getSmallDustByName(String name, int count) {
for (int i = 0; i < types.length; i++) {
if (types[i].equalsIgnoreCase(name)) {
if (types[i].equals(ModItems.META_PLACEHOLDER)) {
throw new InvalidParameterException("The small dust " + name + " could not be found.");
}
2016-03-25 10:47:34 +01:00
return new ItemStack(ModItems.smallDusts, count, i);
}
}
throw new InvalidParameterException("The small dust " + name + " could not be found.");
}
2016-10-08 21:46:16 +02:00
public static ItemStack getSmallDustByName(String name) {
2016-03-25 10:47:34 +01:00
return getSmallDustByName(name, 1);
}
@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;
}
return super.getUnlocalizedName() + "." + types[meta];
}
// Adds Dusts SubItems To Creative Tab
2016-10-08 21:46:16 +02:00
public void getSubItems(Item item, CreativeTabs creativeTabs, List list) {
for (int meta = 0; meta < types.length; ++meta) {
if (!types[meta].equals(ModItems.META_PLACEHOLDER)) {
list.add(new ItemStack(item, 1, meta));
}
2016-03-25 10:47:34 +01:00
}
}
@Override
2016-10-08 21:46:16 +02:00
public String getTextureName(int damage) {
if (types[damage].equals(ModItems.META_PLACEHOLDER)) {
damage = 0;
}
2016-05-13 12:07:56 +02:00
return ModInfo.MOD_ID + ":items/smallDust/small" + StringUtils.toFirstCapital(types[damage]) + "Dust";
2016-03-25 10:47:34 +01:00
}
@Override
2016-10-08 21:46:16 +02:00
public int getMaxMeta() {
2016-03-25 10:47:34 +01:00
return types.length;
}
2015-11-24 23:58:18 +01:00
2015-04-17 00:27:25 +02:00
}