diff --git a/src/main/java/tconstruct/library/TConstructRegistry.java b/src/main/java/tconstruct/library/TConstructRegistry.java index 30585516..b6154723 100644 --- a/src/main/java/tconstruct/library/TConstructRegistry.java +++ b/src/main/java/tconstruct/library/TConstructRegistry.java @@ -258,6 +258,46 @@ public class TConstructRegistry throw new IllegalArgumentException("[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName); } + /** + * Adds a tool material to the registry + * + * @param materialID + * Unique ID, stored for each part + * @param materialName + * Unique name for data lookup purposes + * @param localizationName + * The string used to localize the material name + * @param harvestLevel + * The materials which the tool can harvest. Pickaxe levels - 0: + * Wood, 1: Stone, 2: Redstone/Diamond, 3: Obsidian, 4: + * Cobalt/Ardite, 5: Manyullyn + * @param durability + * Base durability of the tool, affects tool heads. + * @param miningspeed + * Base mining speed, divided by 100 in use + * @param attack + * Base attack + * @param handleModifier + * Durability multiplier on the tool + * @param reinforced + * Reinforced level + * @param stonebound + * Amount of Stonebound to put on the tool. Negative numbers are + * Spiny. + */ + public static void addToolMaterial (int materialID, String materialName, String localizationName, int harvestLevel, int durability, int miningspeed, int attack, float handleModifier, int reinforced, float stonebound, String style, int primaryColor) + { + ToolMaterial mat = toolMaterials.get(materialID); + if (mat == null) + { + mat = new ToolMaterial(materialName, localizationName, harvestLevel, durability, miningspeed, attack, handleModifier, reinforced, stonebound, style, primaryColor); + toolMaterials.put(materialID, mat); + toolMaterialStrings.put(materialName, mat); + } + else + throw new IllegalArgumentException("[TCon API] Material ID " + materialID + " is already occupied by " + mat.materialName); + } + @Deprecated public static void addToolMaterial (int materialID, String materialName, int harvestLevel, int durability, int miningspeed, int attack, float handleModifier, int reinforced, float stonebound, String style) { diff --git a/src/main/java/tconstruct/library/tools/ToolMaterial.java b/src/main/java/tconstruct/library/tools/ToolMaterial.java index f59a1d6e..4a37cce7 100644 --- a/src/main/java/tconstruct/library/tools/ToolMaterial.java +++ b/src/main/java/tconstruct/library/tools/ToolMaterial.java @@ -18,6 +18,8 @@ public class ToolMaterial public final String tipStyle; public final int primaryColor; + private final String localizationString; + @Deprecated public String displayName; @Deprecated @@ -40,6 +42,11 @@ public class ToolMaterial } public ToolMaterial(String name, int level, int durability, int speed, int damage, float handle, int reinforced, float stonebound, String style, int primaryColor) + { + this(name, "material." + name.toLowerCase().replaceAll(" ", ""), level, durability, speed, damage, handle, reinforced, stonebound, style, primaryColor); + } + + public ToolMaterial(String name, String localizationString, int level, int durability, int speed, int damage, float handle, int reinforced, float stonebound, String style, int primaryColor) { this.materialName = name; this.harvestLevel = level; @@ -51,6 +58,8 @@ public class ToolMaterial this.stonebound = stonebound; this.tipStyle = style; this.primaryColor = primaryColor; + + this.localizationString = localizationString; } public String name () @@ -60,14 +69,14 @@ public class ToolMaterial public String localizedName () { - return StatCollector.translateToLocal("material." + materialName.toLowerCase()); + return StatCollector.translateToLocal(localizationString); } public String prefixName () { // check if there's a special name, otherwise use the regular one - if (StatCollector.canTranslate(String.format("material.%s.display", materialName.toLowerCase()))) - return StatCollector.translateToLocal(String.format("material.%s.display", materialName.toLowerCase())); + if (StatCollector.canTranslate(String.format("%s.display", localizationString))) + return StatCollector.translateToLocal(String.format("%s.display", localizationString)); return localizedName(); } @@ -122,8 +131,8 @@ public class ToolMaterial */ public String ability () { - if (StatCollector.canTranslate(String.format("material.%s.ability", materialName.toLowerCase()))) - return StatCollector.translateToLocal(String.format("material.%s.ability", materialName.toLowerCase())); + if (StatCollector.canTranslate(String.format("%s.ability", localizationString))) + return StatCollector.translateToLocal(String.format("%s.ability", localizationString)); return ""; } }