Change item name on part replacement if it's material+tool. (e.g. "Wooden Pickaxe" -> "Flint Pickaxe")

This commit is contained in:
Bernhard Bonigl committed 2014-07-30 16:39:22 +02:00
1 parent 32b09565a4
commit 231d6bca04
3 files changed
+11 -11

No files matched your search

@@ -28,6 +28,7 @@ import java.util.List;
// inofficial todo list:
// todo: find a solution to stone-head-tools not having xp even when head is replaced (maybe like old iguana, disallow stone tools?)
// todo: add randomly generated weapons with random bonuses(!!!!) to dungeon loot :D:D:D
@Mod(modid= Reference.MOD_ID, name= Reference.MOD_NAME, version="1.7.X-1p",
dependencies = "required-after:" + Reference.TCON_MOD_ID + ";after:*")
@@ -143,18 +143,8 @@ public class ModPartReplacement extends ItemModifier {
for(int i = partIndex; i > 0; i--)
partType = detectAdditionalPartType(recipe, replacementPart, partType);
// actually do the exchange
exchangeToolPart(tool, tags, partType, parts[partIndex], itemStack);
/*
// ok. we got the needed info. now we can do the actual exchange :)
int matId = ToolBuilder.instance.getMaterialID(parts[partIndex]);
switch (partType) {
case HEAD: tags.setInteger("Head", matId); tags.setInteger("RenderHead", matId); break;
case HANDLE: tags.setInteger("Handle", matId); tags.setInteger("RenderHandle", matId); break;
case ACCESSORY: tags.setInteger("Accessory", matId); tags.setInteger("RenderAccessory", matId); break;
case EXTRA: tags.setInteger("Extra", matId); tags.setInteger("RenderExtra", matId); break;
}
*/
}
@@ -178,6 +178,15 @@ public abstract class ReplacementLogic {
tags.setInteger("HarvestLevel", tags.getInteger("HarvestLevel") + 1);
}
// Update the tool name if we replaced the head and it was a automagic name
if(type == HEAD) {
String materialName = TConstructRegistry.getMaterial(oldMaterialId).displayName;
String toolName = tool.getToolName();
if (toolStack.getDisplayName().endsWith(materialName + toolName)) {
materialName = TConstructRegistry.getMaterial(partMaterialId).displayName;
toolStack.setStackDisplayName("\u00a7r" + materialName + toolName);
}
}
}
// update tag if it already exists.