2014-06-04 21:44:48 -08:00
|
|
|
package tconstruct.tools.items;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
import java.util.List;
|
2013-12-19 10:05:01 -05:00
|
|
|
import mantle.items.abstracts.CraftingItem;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
2014-09-09 18:30:15 +10:00
|
|
|
import net.minecraft.item.*;
|
2013-08-24 22:36:19 -07:00
|
|
|
import net.minecraft.util.StatCollector;
|
2013-12-19 10:05:01 -05:00
|
|
|
import tconstruct.library.TConstructRegistry;
|
2013-11-04 00:33:39 +01:00
|
|
|
import tconstruct.library.util.IToolPart;
|
2014-06-04 21:44:48 -08:00
|
|
|
import tconstruct.tools.TinkerTools;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
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-12-31 11:26:08 -05:00
|
|
|
public ToolPart(String textureType, String name)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2013-12-31 11:26:08 -05:00
|
|
|
super(toolMaterialNames, buildTextureNames(textureType), "parts/", "tinker", TConstructRegistry.materialTab);
|
2014-04-02 20:38:48 -04:00
|
|
|
this.setCreativeTab(TConstructRegistry.partTab);
|
2013-07-26 21:18:53 -07:00
|
|
|
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
|
2014-02-06 20:17:52 -05:00
|
|
|
public String getItemStackDisplayName (ItemStack par1ItemStack)
|
2013-08-24 22:36:19 -07:00
|
|
|
{
|
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
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/*
|
|
|
|
|
* StringBuilder builder = new StringBuilder();
|
|
|
|
|
* builder.append(StatCollector.translateToLocal("parttype." +
|
|
|
|
|
* toolTextureNames
|
|
|
|
|
* [par1ItemStack.getItemDamage()])).append(" ").append(StatCollector
|
|
|
|
|
* .translateToLocal("toolpart." + partName)); return
|
|
|
|
|
* builder.toString(); -- String s = ("" +
|
|
|
|
|
* StatCollector.translateToLocal("toolpart."+partName)).trim(); String
|
|
|
|
|
* s1 = toolMaterialNames[par1ItemStack.getItemDamage()];
|
|
|
|
|
*
|
|
|
|
|
* if (s1 != null) { s = s + " " + StatCollector.translateToLocal(s1); }
|
|
|
|
|
*
|
|
|
|
|
* return s;
|
|
|
|
|
*/
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-09 18:30:15 +10:00
|
|
|
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", "Pig Iron", "", "", "", "", "", "", "", "", "", "", "", "", "Thaumium" };
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-09-09 18:30:15 +10:00
|
|
|
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", "pigiron", "", "", "", "", "", "", "", "", "", "", "", "", "thaumium" };
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2013-11-04 00:33:39 +01:00
|
|
|
@Override
|
2014-02-07 16:50:54 -05:00
|
|
|
public void getSubItems (Item b, CreativeTabs tab, List list)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2013-11-19 20:57:52 -08:00
|
|
|
for (int i = 0; i < 19; i++)
|
2013-12-31 11:26:08 -05:00
|
|
|
list.add(new ItemStack(b, 1, i));
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-06-04 21:44:48 -08:00
|
|
|
if (TinkerTools.thaumcraftAvailable)
|
2013-12-31 11:26:08 -05:00
|
|
|
list.add(new ItemStack(b, 1, 31));
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getMaterialID (ItemStack stack)
|
|
|
|
|
{
|
2014-09-09 18:30:15 +10:00
|
|
|
if (TConstructRegistry.toolMaterials.keySet().contains(stack.getItemDamage()))
|
2014-08-16 12:20:13 +02:00
|
|
|
return stack.getItemDamage();
|
|
|
|
|
|
|
|
|
|
return -1;
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|