Feature #954: Custom names for specific toolpart and material combinations and tool default names

This commit is contained in:
Qowyn committed 2014-09-13 22:22:11 +02:00
1 parent 593af6be17
commit 7ae5a92a8f
3 files changed
+31 -19

No files matched your search

@@ -2,9 +2,12 @@ package tconstruct.library.crafting;
/** Once upon a time, too many tools to count. Let's put them together automatically */
import cpw.mods.fml.common.eventhandler.Event.Result;
import java.util.*;
import net.minecraft.item.*;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.MinecraftForge;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.event.*;
@@ -428,6 +431,14 @@ public class ToolBuilder
public static String defaultToolName (ToolMaterial headMat, ToolCore tool)
{
String toolName = tool.getToolName().toLowerCase();
String matName = headMat.materialName.toLowerCase().replaceAll(" ", "");
if (StatCollector.canTranslate("tool." + toolName + "." + matName))
{
return StatCollector.translateToLocal("tool." + toolName + "." + matName);
}
return String.format("%s %s", headMat.prefixName(), tool.getLocalizedToolName());
}
@@ -25,26 +25,21 @@ public class ToolPart extends CraftingItem implements IToolPart
@Override
public String getItemStackDisplayName (ItemStack par1ItemStack)
{
String material = StatCollector.translateToLocal("parttype." + toolTextureNames[par1ItemStack.getItemDamage()]);
String name = StatCollector.translateToLocal("toolpart." + partName);
name = name.replaceAll("%%material", material);
String material = toolTextureNames[par1ItemStack.getItemDamage()];
String name = "";
if (StatCollector.canTranslate("toolpart." + partName + "." + material))
{
name = StatCollector.translateToLocal("toolpart." + partName + "." + material);
}
else
{
material = StatCollector.translateToLocal("parttype." + material);
name = StatCollector.translateToLocal("toolpart." + partName);
name = name.replaceAll("%%material", material);
}
return name;
/*
* 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;
*/
}
private static String[] buildTextureNames (String textureType)