use std::collections::HashMap;
use libpso::packet::ship::*;
use libpso::packet::messages::*;
use crate::common::serverstate::ClientId;
use crate::common::leveltable::CharacterLevelTable;
use crate::ship::ship::{SendShipPacket, ShipError, ClientState, Clients};
use crate::ship::character::{CharacterBytesBuilder, FullCharacterBytesBuilder};
use crate::ship::location::{ClientLocation, LobbyId, AreaClient, ClientLocationError};
use crate::entity::character::CharacterEntity;
use crate::ship::items::{ActiveInventory, ActiveItemOnFloor};
use crate::ship::packet::builder::{player_header, player_info};
use std::convert::TryInto;
use libpso::character::character::{Inventory, InventoryItem};
use libpso::utf8_to_utf16_array;


pub fn item_drop(client: u8, target: u8, item_drop: &ActiveItemOnFloor) -> Result<ItemDrop, ShipError> {
    let item_bytes = item_drop.item.as_client_bytes();
    Ok(ItemDrop {
        client: client,
        target: target,
        area: item_drop.map_area.area_value(),
        variety: 0,
        unknown: 0,
        x: item_drop.x,
        z: item_drop.z,
        y: item_drop.y,
        item_bytes: item_bytes[0..12].try_into()?,
        item_id: item_drop.item.id.0,
        item_bytes2: item_bytes[12..16].try_into()?,
        unknown2: 0,
    })
}