From 8d1561cd29f6c02335a5a7cca25abd93b5d98fb7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 17 Apr 2024 13:58:25 -0400 Subject: [PATCH] Update to completion --- .../handlers/ItemProductionMsgHandler.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 28d31f08..2d274623 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -126,26 +126,26 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { private static void completeItem(int itemUUID, NPC vendor) { - Item virtualItem = ForgeManager.inMemoryItemLookup.get(itemUUID); + WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); - if (virtualItem == null) - return; - - //remove from client forge window - - ItemProductionMsg outMsg = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.SETPRICE, true); - DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - - // Add to NPC inventory + // Persist item and add to vendor inventory + Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem); vendor.charItemManager.addItemToInventory(virtualItem); + ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg2 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + // Remove from collections - WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); + ItemProductionMsg outMsg = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + workOrder.cooking.remove(virtualItem); - ForgeManager.vendorItemLookup.get(vendor).remove(virtualItem); + ForgeManager.vendorItemLookup.get(workOrder.vendor).remove(virtualItem); ForgeManager.itemWorkOrderLookup.remove(virtualItem);