// unequip if needed
if (itemToRemove.isEquipped())
{
L2ItemInstance[] unequiped = activeChar.getInventory()
.unEquipItemInSlotAndRecord(itemToRemove.getEquipSlot());
InventoryUpdate iu = new InventoryUpdate();
for (int i = 0; i < unequiped.length; i++)
{
iu.addModifiedItem(unequiped[i]);
}
activeChar.sendPacket(iu);
// activeChar.updatePDef();
// activeChar.updatePAtk();
// activeChar.updateMDef();
// activeChar.updateMAtk();
// activeChar.updateAccuracy();
// activeChar.updateCriticalChance();
}
// remove from inventory
L2ItemInstance removedItem = activeChar.getInventory().destroyItem(
"Crystalize", _objectId, _count, activeChar, null);
// add crystals
int crystalId = itemToRemove.getItem().getCrystalItemId();
int crystalAmount = itemToRemove.getCrystalCount();
L2ItemInstance createditem = activeChar.getInventory().addItem(
"Crystalize", crystalId, crystalAmount, activeChar,
itemToRemove);
SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
sm.addItemName(crystalId);
sm.addNumber(crystalAmount);
activeChar.sendPacket(sm);
sm = null;
// send inventory update
if (!Config.FORCE_INVENTORY_UPDATE)
{
InventoryUpdate iu = new InventoryUpdate();
if (removedItem.getCount() == 0)
iu.addRemovedItem(removedItem);
else
iu.addModifiedItem(removedItem);
if (createditem.getCount() != crystalAmount)
iu.addModifiedItem(createditem);
else
iu.addNewItem(createditem);
activeChar.sendPacket(iu);
} else
activeChar.sendPacket(new ItemList(activeChar, false));