mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-21 20:52:26 +00:00
Change default tool names to the same as the creative tool names, and still allow renaming. Also unify it for station and forge.
This commit is contained in:
1 parent
4c410e6de6
commit
8e5fa1118d
3 files changed
+66
-53
No files matched your search
@@ -69,32 +69,7 @@ public class ToolForgeLogic extends ToolStationLogic implements ISidedInventory
|
||||
}
|
||||
}
|
||||
if (!name.equals("")) //Name item
|
||||
{
|
||||
ItemStack temp = inventory[1].copy();
|
||||
if (output != null)
|
||||
temp = output;
|
||||
|
||||
if (temp != null)
|
||||
{
|
||||
NBTTagCompound tags = temp.getTagCompound();
|
||||
if (tags == null)
|
||||
{
|
||||
tags = new NBTTagCompound();
|
||||
temp.setTagCompound(tags);
|
||||
}
|
||||
|
||||
if (!(tags.hasKey("display")))
|
||||
{
|
||||
NBTTagCompound display = new NBTTagCompound();
|
||||
String dName = temp.getItem() instanceof IModifyable ? "\u00A7f" + name : name;
|
||||
display.setString("Name", dName);
|
||||
tags.setTag("display", display);
|
||||
temp.setRepairCost(2);
|
||||
output = temp;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
output = tryRenameTool(output, name);
|
||||
}
|
||||
inventory[0] = output;
|
||||
}
|
||||
|
||||
@@ -100,32 +100,7 @@ public class ToolStationLogic extends InventoryLogic implements ISidedInventory
|
||||
}
|
||||
}
|
||||
if (!name.equals("")) //Name item
|
||||
{
|
||||
ItemStack temp = inventory[1].copy();
|
||||
if (output != null)
|
||||
temp = output;
|
||||
|
||||
if (temp != null)
|
||||
{
|
||||
NBTTagCompound tags = temp.getTagCompound();
|
||||
if (tags == null)
|
||||
{
|
||||
tags = new NBTTagCompound();
|
||||
temp.setTagCompound(tags);
|
||||
}
|
||||
|
||||
if (!(tags.hasKey("display")))
|
||||
{
|
||||
NBTTagCompound display = new NBTTagCompound();
|
||||
String dName = temp.getItem() instanceof IModifyable ? "\u00A7f" + name : name;
|
||||
display.setString("Name", dName);
|
||||
tags.setTag("display", display);
|
||||
temp.setRepairCost(2);
|
||||
output = temp;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
output = tryRenameTool(output, name);
|
||||
}
|
||||
inventory[0] = output;
|
||||
}
|
||||
@@ -136,6 +111,47 @@ public class ToolStationLogic extends InventoryLogic implements ISidedInventory
|
||||
buildTool(name);
|
||||
}
|
||||
|
||||
protected ItemStack tryRenameTool(ItemStack output, String name)
|
||||
{
|
||||
ItemStack temp = inventory[1].copy();
|
||||
if (output != null)
|
||||
temp = output;
|
||||
|
||||
if (temp != null)
|
||||
{
|
||||
NBTTagCompound tags = temp.getTagCompound();
|
||||
if (tags == null)
|
||||
{
|
||||
tags = new NBTTagCompound();
|
||||
temp.setTagCompound(tags);
|
||||
}
|
||||
|
||||
if (!(tags.hasKey("display")))
|
||||
{
|
||||
NBTTagCompound display = new NBTTagCompound();
|
||||
String dName = temp.getItem() instanceof IModifyable ? "\u00A7f" + name : name;
|
||||
display.setString("Name", dName);
|
||||
tags.setTag("display", display);
|
||||
temp.setRepairCost(2);
|
||||
output = temp;
|
||||
}
|
||||
else if(tags.getCompoundTag("display").hasKey("Name"))
|
||||
{
|
||||
NBTTagCompound display = tags.getCompoundTag("display");
|
||||
if(display.getString("Name").equals("\u00A7f" + ToolBuilder.defaultToolName(temp)))
|
||||
{
|
||||
String dName = temp.getItem() instanceof IModifyable ? "\u00A7f" + name : name;
|
||||
display.setString("Name", dName);
|
||||
tags.setTag("display", display);
|
||||
temp.setRepairCost(2);
|
||||
output = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user