From 48f88ec819e2550acd24e53c868f7868ebcaaa68 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 15:11:10 -0400 Subject: [PATCH] Serialization update --- src/engine/net/client/msg/ManageNPCMsg.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index c4898efa..b0c9f5e8 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -27,8 +27,6 @@ import org.pmw.tinylog.Logger; import java.util.ArrayList; import java.util.HashSet; -import java.util.List; -import java.util.stream.Collectors; /** * Order NPC @@ -436,12 +434,13 @@ public class ManageNPCMsg extends ClientNetMsg { writer.put((byte) template.modTable);//EffectItemType } - List itemList = ForgeManager.vendorItemLookup.get(npc); - itemList = itemList.stream().limit(npc.getRank()).collect(Collectors.toList()); + // Sanity check. - writer.putInt(itemList.size()); + ForgeManager.vendorItemLookup.computeIfAbsent(npc, k -> new ArrayList<>()); // Forge lookup - for (Item item : itemList) { + writer.putInt(ForgeManager.vendorItemLookup.get(npc).size()); + + for (Item item : ForgeManager.vendorItemLookup.get(npc)) { writer.put((byte) 0); // ? Unknown45 writer.putInt(item.getObjectType().ordinal());