Files
TinkersConstruct/src/tconstruct/items/ToolPart.java
T

81 lines
2.9 KiB
Java
Raw Normal View History

package tconstruct.items;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
2013-08-24 22:36:19 -07:00
import net.minecraft.util.StatCollector;
2013-11-04 00:33:39 +01:00
import tconstruct.common.TContent;
import tconstruct.library.util.IToolPart;
public class ToolPart extends CraftingItem implements IToolPart
{
2013-08-24 22:36:19 -07:00
public String partName;
2013-08-31 05:13:31 -07:00
2013-08-24 22:36:19 -07:00
public ToolPart(int id, String textureType, String name)
{
super(id, toolMaterialNames, buildTextureNames(textureType), "parts/");
this.setHasSubtypes(true);
this.setMaxDamage(0);
2013-08-24 22:36:19 -07:00
this.partName = name;
}
2013-08-31 05:13:31 -07:00
2013-08-24 22:36:19 -07:00
@Override
public String getItemDisplayName (ItemStack par1ItemStack)
{
2013-10-16 17:37:33 +11:00
String material = StatCollector.translateToLocal("parttype." + toolTextureNames[par1ItemStack.getItemDamage()]);
String name = StatCollector.translateToLocal("toolpart." + partName);
name = name.replaceAll("%%material", material);
return name;
2013-11-04 00:33:39 +01:00
2013-10-16 17:37:33 +11:00
/*StringBuilder builder = new StringBuilder();
2013-08-31 05:13:31 -07:00
builder.append(StatCollector.translateToLocal("parttype." + toolTextureNames[par1ItemStack.getItemDamage()])).append(" ").append(StatCollector.translateToLocal("toolpart." + partName));
2013-08-24 22:36:19 -07:00
return builder.toString();
2013-10-16 17:37:33 +11:00
--
String s = ("" + StatCollector.translateToLocal("toolpart."+partName)).trim();
2013-08-24 22:36:19 -07:00
String s1 = toolMaterialNames[par1ItemStack.getItemDamage()];
if (s1 != null)
{
s = s + " " + StatCollector.translateToLocal(s1);
}
return s;*/
}
private static String[] buildTextureNames (String textureType)
{
String[] names = new String[toolMaterialNames.length];
for (int i = 0; i < toolMaterialNames.length; i++)
{
if (toolTextureNames[i].equals(""))
names[i] = "";
else
names[i] = toolTextureNames[i] + textureType;
}
return names;
}
public static final String[] toolMaterialNames = new String[] { "Wood", "Stone", "Iron", "Flint", "Cactus", "Bone", "Obsidian", "Netherrack", "Slime", "Paper", "Cobalt", "Ardite", "Manyullyn",
"Copper", "Bronze", "Alumite", "Steel", "Blue Slime", "", "", "", "", "", "", "", "", "", "", "", "", "", "Thaumium" };
public static final String[] toolTextureNames = new String[] { "wood", "stone", "iron", "flint", "cactus", "bone", "obsidian", "netherrack", "slime", "paper", "cobalt", "ardite", "manyullyn",
"copper", "bronze", "alumite", "steel", "blueslime", "", "", "", "", "", "", "", "", "", "", "", "", "", "thaumium" };
2013-11-04 00:33:39 +01:00
@Override
public void getSubItems (int id, CreativeTabs tab, List list)
{
2013-11-04 00:33:39 +01:00
for (int i = 0; i < 18; i++)
list.add(new ItemStack(id, 1, i));
if (TContent.thaumcraftAvailable)
list.add(new ItemStack(id, 1, 31));
}
@Override
public int getMaterialID (ItemStack stack)
{
return stack.getItemDamage();
}
}