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);