From 7cab7536a1c2f634ba75a63bb4e685c0e9d755bc Mon Sep 17 00:00:00 2001 From: mDiyo Date: Sun, 10 Nov 2013 19:07:39 -0800 Subject: [PATCH] Unnamed tools can be named when modified --- src/tconstruct/library/crafting/ToolBuilder.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/tconstruct/library/crafting/ToolBuilder.java b/src/tconstruct/library/crafting/ToolBuilder.java index 3cd6df3a..fe330787 100644 --- a/src/tconstruct/library/crafting/ToolBuilder.java +++ b/src/tconstruct/library/crafting/ToolBuilder.java @@ -129,7 +129,7 @@ public class ToolBuilder public ItemStack buildTool (ItemStack headStack, ItemStack handleStack, ItemStack accessoryStack, ItemStack extraStack, String name) { if (headStack != null && headStack.getItem() instanceof ToolCore) - return modifyTool(headStack, handleStack, accessoryStack, extraStack); + return modifyTool(headStack, handleStack, accessoryStack, extraStack, name); if (headStack == null || handleStack == null) //Nothing to build without these. All tools need at least two parts! return null; @@ -356,7 +356,7 @@ public class ToolBuilder return tool; } - public ItemStack modifyTool (ItemStack input, ItemStack topSlot, ItemStack bottomSlot, ItemStack extraStack) + public ItemStack modifyTool (ItemStack input, ItemStack topSlot, ItemStack bottomSlot, ItemStack extraStack, String name) { if (extraStack != null) return null; @@ -379,6 +379,13 @@ public class ToolBuilder mod.modify(slots, tool); } } + + tags = tool.getTagCompound(); + if (name != null && !name.equals("") && !tags.hasKey("display")) + { + tags.setCompoundTag("display", new NBTTagCompound()); + tags.getCompoundTag("display").setString("Name", "\u00A7f" + name); + } if (built) return tool;