From dbf67f37eb84c320329039b80c5c06e03d5ec203 Mon Sep 17 00:00:00 2001 From: RiggZh Date: Thu, 17 Apr 2025 09:19:37 +0800 Subject: [PATCH] Revert "fix: completely duplicated extends code" This reverts commit c2c5792e84ce18e63d2e007c6370f34261097419. --- .../tools/logic/ToolForgeLogic.java | 55 ++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/src/main/java/tconstruct/tools/logic/ToolForgeLogic.java b/src/main/java/tconstruct/tools/logic/ToolForgeLogic.java index d0930958..5c85edd4 100644 --- a/src/main/java/tconstruct/tools/logic/ToolForgeLogic.java +++ b/src/main/java/tconstruct/tools/logic/ToolForgeLogic.java @@ -2,18 +2,29 @@ package tconstruct.tools.logic; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import tconstruct.TConstruct; +import tconstruct.library.crafting.ModifyBuilder; +import tconstruct.library.crafting.ToolBuilder; +import tconstruct.library.modifier.IModifyable; import tconstruct.tools.inventory.ToolForgeContainer; +import tconstruct.util.network.ToolStationPacket; /* * Simple class for storing items in the block */ -public class ToolForgeLogic extends ToolStationLogic { +public class ToolForgeLogic extends ToolStationLogic implements ISidedInventory { + + ItemStack previousTool; + String toolName; public ToolForgeLogic() { super(6); + toolName = ""; } @Override @@ -25,4 +36,46 @@ public class ToolForgeLogic extends ToolStationLogic { public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) { return new ToolForgeContainer(inventoryplayer, this); } + + @Override + public void buildTool(String name) { + ItemStack output = null; + if (inventory[1] != null) { + if (inventory[1].getItem() instanceof IModifyable) // Modify item + { + if (inventory[2] == null && inventory[3] == null && inventory[4] == null) output = inventory[1].copy(); + else { + output = ModifyBuilder.instance + .modifyItem(inventory[1], new ItemStack[] { inventory[2], inventory[3], inventory[4] }); + } + } else + // Build new item + { + toolName = name; + ItemStack tool = ToolBuilder.instance + .buildTool(inventory[1], inventory[2], inventory[3], inventory[4], name); + if (inventory[0] == null) output = tool; + else if (tool != null) { + // NBTTagCompound tags = tool.getTagCompound(); + // if (!tags.getCompoundTag(((IModifyable) tool.getItem()).getBaseTagName()).hasKey("Built")) + // { + output = tool; + // } + } + } + if (!name.equals("")) // Name item + output = tryRenameTool(output, name); + } + inventory[0] = output; + if (output != null && output.hasDisplayName()) { + TConstruct.packetPipeline + .sendToServer(new ToolStationPacket(xCoord, yCoord, zCoord, output.getDisplayName())); + } + } + /* + * public void buildTool (String name) { toolName = name; ItemStack tool = + * ToolBuilder.instance.buildTool(inventory[1], inventory[2], inventory[3], inventory[4], name); if (inventory[0] == + * null) inventory[0] = tool; else { NBTTagCompound tags = inventory[0].getTagCompound(); if + * (!tags.getCompoundTag("InfiTool").hasKey("Built")) { inventory[0] = tool; } } } + */ }