private void UpdateNpc(NecClient client, NpcSpawn npcSpawn)
        {
            if (client.character.eventSelectExecCode == 0)
            {
                npcSpawn.heading = (byte)(client.character.heading + 90);
                npcSpawn.heading = (byte)(npcSpawn.heading % 180);
                if (npcSpawn.heading < 0)
                {
                    npcSpawn.heading += 180;
                }

                npcSpawn.updated = DateTime.Now;


                if (!server.database.UpdateNpcSpawn(npcSpawn))
                {
                    IBuffer res12 = BufferProvider.Provide();
                    res12.WriteCString("Could not update the database"); // Length 0xC01
                    router.Send(client, (ushort)AreaPacketId.recv_event_system_message, res12,
                                ServerType.Area);                        // show system message on middle of the screen.
                    return;
                }

                IBuffer res13 = BufferProvider.Provide();
                res13.WriteCString("NPC Updated"); // Length 0xC01
                router.Send(client, (ushort)AreaPacketId.recv_event_system_message, res13,
                            ServerType.Area);      // show system message on middle of the screen.

                RecvEventEnd(client);              //End The Event
            }
            else if (client.character.eventSelectExecCode == 1)
            {
                NpcModelUpdate npcModelUpdate = new NpcModelUpdate();
                server.instances.AssignInstance(npcModelUpdate);
                npcModelUpdate.npcSpawn = npcSpawn;

                client.character.currentEvent = npcModelUpdate;

                IBuffer             res14      = BufferProvider.Provide();
                RecvEventRequestInt getModelId = new RecvEventRequestInt("Select Model ID from Model_common.csv", 11000,
                                                                         1911105, npcSpawn.modelId);
                router.Send(getModelId, client);
            }
        }
        public override void Handle(NecClient client, NecPacket packet)
        {
            byte
                toStoreType =
                packet.Data
                .ReadByte();         // [0 = adventure bag. 1 = character equipment], [then unknown byte], [then slot], [then unknown]
            byte  toBagId       = packet.Data.ReadByte();
            short fromSlot      = packet.Data.ReadInt16();
            byte  fromStoreType = packet.Data.ReadByte();
            byte  fromBagId     = packet.Data.ReadByte();
            short toSlot        = packet.Data.ReadInt16();

            Logger.Debug($"fromStoreType byte [{fromStoreType}]");
            Logger.Debug($"fromBagId byte [{fromBagId}]");
            Logger.Debug($"fromSlot byte [{fromSlot}]");
            Logger.Debug($"toStoreType byte [{toStoreType}]");
            Logger.Debug($"toBagId byte [{toBagId}]");
            Logger.Debug($"toSlot [{toSlot}]");

            int itemCount = packet.Data.ReadByte(); //last byte is stack count?

            Logger.Debug($"itemCount [{itemCount}]");
            IBuffer res = BufferProvider.Provide();

            res.WriteInt32(0); //error check. 0 to work

            /*
             *  ITEMUSE	GENERIC	Unable to use this item right now
             *  ITEMUSE	-201	Store location is incorrect
             *  ITEMUSE	-204	Item amount is incorrect
             *  ITEMUSE	-205	The target to use this item is incorrect
             *  ITEMUSE	-206	Unable to use due to delay time
             *  ITEMUSE	-207	No space available in inventory
             *  ITEMUSE	-208	Unable to use this item since it is cursed
             *  ITEMUSE	-209	Unable to use this item since it is broken
             *  ITEMUSE	-210	You do not meet the requirements to equip this item
             *  ITEMUSE	-211	Unable to use this item
             *  ITEMUSE	-212	You are not in the right status to use this item
             *  ITEMUSE	-230	Unable to use since it is on cool down.
             *  ITEMUSE	-2601	You've already received this scrap
             *  ITEMUSE	-2708	Cannot be used outside of town
             *  ITEMUSE	-3001	Unable to move items when you have a shop open
             *
             */

            Router.Send(client, (ushort)AreaPacketId.recv_item_move_r, res, ServerType.Area);

            InventoryItem fromInvItem = client.Character.GetInventoryItem(fromStoreType, fromBagId, fromSlot);
            InventoryItem toInvItem   = client.Character.GetInventoryItem(toStoreType, toBagId, toSlot);

            if (toInvItem != null && (fromInvItem.StorageItem != toInvItem.StorageItem))
            {
                RecvNormalSystemMessage unlikeItems = new RecvNormalSystemMessage("You can only stack like items!");
                _server.Router.Send(unlikeItems, client);
                return;
            }

            if (toInvItem != null && (toInvItem.StorageCount >= 255))
            {
                RecvNormalSystemMessage unlikeItems =
                    new RecvNormalSystemMessage("The move would place too many items in destination slot!");
                _server.Router.Send(unlikeItems, client);
                return;
            }

            if (fromInvItem.StorageCount > 1)
            {
                if (client.Character.currentEvent != null)
                {
                    Logger.Error(
                        $"Trying to start new event with another outstanding event active! Outstanding event type [{client.Character.currentEvent.EventType}]");
                    client.Character.currentEvent = null;
                }

                MoveItem moveItem = _server.Instances.CreateInstance <MoveItem>();
                moveItem.toStoreType          = toStoreType;
                moveItem.toBagId              = toBagId;
                moveItem.toSlot               = toSlot;
                moveItem.fromStoreType        = fromStoreType;
                moveItem.fromBagId            = moveItem.fromBagId;
                moveItem.fromSlot             = fromSlot;
                moveItem.itemCount            = (byte)itemCount;
                moveItem.item                 = fromInvItem.StorageItem;
                client.Character.currentEvent = moveItem;
                RecvEventStart eventStart = new RecvEventStart(0, 0);
                Router.Send(eventStart, client);
                RecvEventRequestInt getCount = new RecvEventRequestInt("Select number to move.", 1,
                                                                       fromInvItem.StorageCount, fromInvItem.StorageCount);
                Router.Send(getCount, client);
            }
            else
            {
                if (toInvItem == null)
                {
                    fromInvItem.StorageType = toStoreType;
                    fromInvItem.StorageId   = toBagId;
                    fromInvItem.StorageSlot = toSlot;
                    client.Character.UpdateInventoryItem(fromInvItem);
                    RecvItemUpdatePlace changePlace =
                        new RecvItemUpdatePlace(fromInvItem.InstanceId, toStoreType, toBagId, toSlot);
                    _server.Router.Send(changePlace, client);
                    client.Character.UpdateInventoryItem(fromInvItem);
                }
                else
                {
                    toInvItem.StorageCount += 1;
                    RecvItemUpdateNum updateNum = new RecvItemUpdateNum(toInvItem.InstanceId, toInvItem.StorageCount);
                    _server.Router.Send(updateNum, client);
                    RecvItemRemove removeitem = new RecvItemRemove(fromInvItem.InstanceId);
                    _server.Router.Send(removeitem, client);
                    client.Character.UpdateInventoryItem(toInvItem);
                    client.Character.RemoveInventoryItem(fromInvItem);
                }
            }

            //SendItemPlace(client);
            //SendItemPlaceChange(client);
        }