Search in sources :

Example 1 with EnchantmentEntry

use of cn.nukkit.item.enchantment.EnchantmentEntry in project Nukkit by Nukkit.

the class CraftingDataPacket method writeEnchantList.

private static int writeEnchantList(EnchantmentList list, BinaryStream stream) {
    stream.putByte((byte) list.getSize());
    for (int i = 0; i < list.getSize(); ++i) {
        EnchantmentEntry entry = list.getSlot(i);
        stream.putUnsignedVarInt(entry.getCost());
        stream.putUnsignedVarInt(entry.getEnchantments().length);
        for (Enchantment enchantment : entry.getEnchantments()) {
            stream.putUnsignedVarInt(enchantment.getId());
            stream.putUnsignedVarInt(enchantment.getLevel());
        }
        stream.putString(entry.getRandomName());
    }
    return CraftingDataPacket.ENTRY_ENCHANT_LIST;
}
Also used : EnchantmentEntry(cn.nukkit.item.enchantment.EnchantmentEntry) Enchantment(cn.nukkit.item.enchantment.Enchantment)

Aggregations

Enchantment (cn.nukkit.item.enchantment.Enchantment)1 EnchantmentEntry (cn.nukkit.item.enchantment.EnchantmentEntry)1