From 85e5e2a7e35beabbc0f8024a9bb903bbcb7cb66a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 15:17:32 -0400 Subject: [PATCH] Init forge support only for valid contracts --- src/engine/net/client/msg/ManageNPCMsg.java | 4 ---- src/engine/objects/NPC.java | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index b0c9f5e8..2b54b69d 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -434,10 +434,6 @@ public class ManageNPCMsg extends ClientNetMsg { writer.put((byte) template.modTable);//EffectItemType } - // Sanity check. - - ForgeManager.vendorItemLookup.computeIfAbsent(npc, k -> new ArrayList<>()); // Forge lookup - writer.putInt(ForgeManager.vendorItemLookup.get(npc).size()); for (Item item : ForgeManager.vendorItemLookup.get(npc)) { diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 6fd40f84..7bca7160 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -869,6 +869,11 @@ public class NPC extends AbstractCharacter { if (this.building != null) NPCManager.slotCharacterInBuilding(this); + // If NPC is a vendor create arraylist for forge + + if (this.contract.isTrainer() == false) + ForgeManager.vendorItemLookup.computeIfAbsent(this, k -> new ArrayList<>()); // Forge lookup + this.symbol = this.contract.getIconID(); this.modTypeTable = this.contract.getNPCModTypeTable(); this.modSuffixTable = this.contract.getNpcModSuffixTable();