if(newItem == null)
return null;
// Send inventory update packet
PetInventoryUpdate petIU = new PetInventoryUpdate();
if(oldItem.getCount() > 0 && oldItem != newItem)
{
petIU.addModifiedItem(oldItem);
}
else
{
petIU.addRemovedItem(oldItem);
}
getOwner().sendPacket(petIU);
oldItem = null;
petIU = null;
// Send target update packet
if(target instanceof PcInventory)
{
L2PcInstance targetPlayer = ((PcInventory) target).getOwner();
InventoryUpdate playerUI = new InventoryUpdate();
if(newItem.getCount() > count)
{
playerUI.addModifiedItem(newItem);
}
else
{
playerUI.addNewItem(newItem);
}
targetPlayer.sendPacket(playerUI);
playerUI = null;
// Update current load as well
StatusUpdate playerSU = new StatusUpdate(targetPlayer.getObjectId());
playerSU.addAttribute(StatusUpdate.CUR_LOAD, targetPlayer.getCurrentLoad());
targetPlayer.sendPacket(playerSU);
playerSU = null;
targetPlayer = null;
}
else if(target instanceof PetInventory)
{
petIU = new PetInventoryUpdate();
if(newItem.getCount() > count)
{
petIU.addRemovedItem(newItem);
}
else
{
petIU.addNewItem(newItem);
}
((PetInventory) target).getOwner().getOwner().sendPacket(petIU);
petIU = null;
}
return newItem;