2015-04-11 01:12:59 +02:00
|
|
|
package techreborn.items;
|
|
|
|
|
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
2015-06-26 08:09:45 +02:00
|
|
|
import net.minecraft.init.Items;
|
2015-04-11 01:12:59 +02:00
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2015-04-18 12:47:09 +02:00
|
|
|
import techreborn.client.TechRebornCreativeTabMisc;
|
2015-06-07 06:36:37 +02:00
|
|
|
import techreborn.init.ModItems;
|
2015-11-24 23:58:18 +01:00
|
|
|
import techreborn.lib.ModInfo;
|
2015-04-15 17:23:12 +02:00
|
|
|
|
2016-04-30 06:21:28 +02:00
|
|
|
import java.security.InvalidParameterException;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class ItemDusts extends ItemTextureBase
|
|
|
|
{
|
|
|
|
public static final String[] types = new String[] { "almandine", "aluminum", "andradite", "ashes", "basalt",
|
|
|
|
"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", "redrock",
|
|
|
|
"ruby", "saltpeter", "sapphire", "sawDust", "silver", "sodalite", "spessartine", "sphalerite", "steel",
|
2016-05-22 15:53:56 +02:00
|
|
|
"sulfur", "tin", "titanium", "tungsten", "uvarovite", "%NULL%", "yellowGarnet", "zinc",
|
2016-03-29 04:47:00 +02:00
|
|
|
"olivine" };
|
2016-03-25 10:47:34 +01:00
|
|
|
|
2016-04-30 06:21:28 +02:00
|
|
|
public ItemDusts()
|
|
|
|
{
|
2016-03-25 10:47:34 +01:00
|
|
|
setUnlocalizedName("techreborn.dust");
|
|
|
|
setHasSubtypes(true);
|
|
|
|
setCreativeTab(TechRebornCreativeTabMisc.instance);
|
|
|
|
}
|
|
|
|
|
2016-04-30 06:21:28 +02:00
|
|
|
public static ItemStack getDustByName(String name, int count)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < types.length; i++)
|
|
|
|
{
|
|
|
|
if (types[i].equalsIgnoreCase(name))
|
|
|
|
{
|
2016-05-22 15:53:56 +02:00
|
|
|
if(types[i].equals("%NULL%")){
|
|
|
|
throw new InvalidParameterException("The dust " + name + " could not be found.");
|
|
|
|
}
|
2016-03-25 10:47:34 +01:00
|
|
|
return new ItemStack(ModItems.dusts, count, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-30 06:21:28 +02:00
|
|
|
if (name.equalsIgnoreCase("glowstone"))
|
|
|
|
{
|
2016-05-06 23:13:24 +02:00
|
|
|
return new ItemStack(Items.GLOWSTONE_DUST, count);
|
2016-03-25 10:47:34 +01:00
|
|
|
}
|
2016-04-30 06:21:28 +02:00
|
|
|
if (name.equalsIgnoreCase("redstone"))
|
|
|
|
{
|
2016-05-06 23:13:24 +02:00
|
|
|
return new ItemStack(Items.REDSTONE, count);
|
2016-03-25 10:47:34 +01:00
|
|
|
}
|
2016-04-30 06:21:28 +02:00
|
|
|
if (name.equalsIgnoreCase("gunpowder"))
|
|
|
|
{
|
2016-05-06 23:13:24 +02:00
|
|
|
return new ItemStack(Items.GUNPOWDER, count);
|
2016-03-25 10:47:34 +01:00
|
|
|
}
|
|
|
|
throw new InvalidParameterException("The dust " + name + " could not be found.");
|
|
|
|
}
|
|
|
|
|
2016-04-30 06:21:28 +02:00
|
|
|
public static ItemStack getDustByName(String name)
|
|
|
|
{
|
2016-03-25 10:47:34 +01:00
|
|
|
return getDustByName(name, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
// gets Unlocalized Name depending on meta data
|
2016-04-30 06:21:28 +02:00
|
|
|
public String getUnlocalizedName(ItemStack itemStack)
|
|
|
|
{
|
2016-03-25 10:47:34 +01:00
|
|
|
int meta = itemStack.getItemDamage();
|
2016-04-30 06:21:28 +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-04-30 06:21:28 +02:00
|
|
|
public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
|
|
|
|
{
|
|
|
|
for (int meta = 0; meta < types.length; ++meta)
|
|
|
|
{
|
2016-05-22 15:53:56 +02:00
|
|
|
if(!types[meta].equals("%NULL%")){
|
|
|
|
list.add(new ItemStack(item, 1, meta));
|
|
|
|
}
|
2016-03-25 10:47:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-30 06:21:28 +02:00
|
|
|
@Override public String getTextureName(int damage)
|
|
|
|
{
|
2016-05-22 15:53:56 +02:00
|
|
|
if(types[damage].equals("%NULL%")){
|
|
|
|
damage = 0;
|
|
|
|
}
|
2016-03-25 10:47:34 +01:00
|
|
|
return ModInfo.MOD_ID + ":items/dust/" + types[damage] + "Dust";
|
|
|
|
}
|
|
|
|
|
2016-04-30 06:21:28 +02:00
|
|
|
@Override public int getMaxMeta()
|
|
|
|
{
|
2016-03-25 10:47:34 +01:00
|
|
|
return types.length;
|
|
|
|
}
|
2015-11-24 23:58:18 +01:00
|
|
|
|
2015-04-11 01:12:59 +02:00
|
|
|
}
|