protected void writeItemInfo(ItemInfo item, long count, boolean writeSize, int initSize)
{
int size = initSize + 45;
int flags = 0;
if(item.getVariation1Id() > 0 || item.getVariation2Id() > 0)
{
size += 8;
flags |= IS_AUGMENTED;
}
int attackElementValue = item.getAttackElementValue();
int defenceFire = item.getDefenceFire();
int defenceWater = item.getDefenceWater();
int defenceWind = item.getDefenceWind();
int defenceEarth = item.getDefenceEarth();
int defenceHoly = item.getDefenceHoly();
int defenceUnholy = item.getDefenceUnholy();
if(attackElementValue > 0 || defenceFire > 0 || defenceWater > 0 || defenceWind > 0 || defenceEarth > 0 || defenceHoly > 0 || defenceUnholy > 0)
{
size += 16;
flags |= IS_ELEMENTED;
}
/*for(int enchantOption : item.getEnchantOptions())
{
if(enchantOption > 0)
{
flags |= HAVE_ENCHANT_OPTIONS;
break;
}
}*/
if(item.getVisualId() > 0)
{
size += 4;
flags |= VISUAL_CHANGED;
}
Ensoul[] normalEnsouls = item.getNormalEnsouls();
Ensoul[] specialEnsouls = item.getSpecialEnsouls();
if(normalEnsouls.length > 0 || specialEnsouls.length > 0)
{
size += 2 + (normalEnsouls.length * 4) + (specialEnsouls.length * 4);
flags |= HAVE_ENSOUL;
}
if (writeSize)
{
writeD(size);
}
writeH(flags);
writeD(item.getObjectId()); // ObjectId
writeD(item.getItemId()); // ItemId
writeC(item.isEquipped() ? 0xFF : item.getEquipSlot()); // T1
writeQ(count); // Quantity
writeC(item.getItem().getType2()); // Item Type 2 : 00-weapon, 01-shield/armor, 02-ring/earring/necklace, 03-questitem, 04-adena, 05-item
writeC(item.getCustomType1()); // Filler (always 0)
writeH(item.isEquipped() ? 1 : 0); // Equipped : 00-No, 01-yes
writeQ(item.getItem().getBodyPart()); // Slot : 0006-lr.ear, 0008-neck, 0030-lr.finger, 0040-head, 0100-l.hand, 0200-gloves, 0400-chest, 0800-pants, 1000-feet, 4000-r.hand, 8000-r.hand
writeH(item.getEnchantLevel()); // Enchant level (pet level shown in control item)
writeD(item.getDurability());
//writeC(item.getCustomType2());
writeC(0); // 270 protocol
//writeD(item.getShadowLifeTime());
writeD(item.getDurability() > 0 ? item.getDurability() : -9999);
//writeD(item.getTemporalLifeTime());
writeC(!item.isBlocked()); // GOD Item enabled = 1 disabled (red) = 0
writeH(0x00); // 140 PROTOCOL
if((flags & IS_AUGMENTED) == IS_AUGMENTED)
{
writeD(item.getVariation1Id());
writeD(item.getVariation2Id());
writeD(item.getVariation3Id());
}
if((flags & IS_ELEMENTED) == IS_ELEMENTED)
{
writeH(item.getAttackElement());
writeH(attackElementValue);
writeH(defenceFire);
writeH(defenceWater);
writeH(defenceWind);
writeH(defenceEarth);
writeH(defenceHoly);
writeH(defenceUnholy);
}
/*if((flags & HAVE_ENCHANT_OPTIONS) == HAVE_ENCHANT_OPTIONS)
{
writeD(item.getEnchantOptions()[0]);
writeD(item.getEnchantOptions()[1]);
writeD(item.getEnchantOptions()[2]);
}*/
if((flags & VISUAL_CHANGED) == VISUAL_CHANGED)
{
writeD(item.getVisualId());
}
if((flags & HAVE_ENSOUL) == HAVE_ENSOUL)
{
writeC(normalEnsouls.length);
for(Ensoul ensoul : normalEnsouls)
{
writeD(ensoul.getId());
}
writeC(specialEnsouls.length);
for(Ensoul ensoul : specialEnsouls)
{
writeD(ensoul.getId());
}
}
//if((flags & REUSE_DELAY) == REUSE_DELAY)
// writeD(0x00);
}