Search in sources :

Example 1 with ItemCoal

use of cn.nukkit.item.ItemCoal in project Nukkit by Nukkit.

the class BlockOreCoal method getDrops.

@Override
public Item[] getDrops(Item item) {
    if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) {
        int count = 1;
        Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
        if (fortune != null && fortune.getLevel() >= 1) {
            int i = ThreadLocalRandom.current().nextInt(fortune.getLevel() + 2) - 1;
            if (i < 0) {
                i = 0;
            }
            count = i + 1;
        }
        return new Item[] { new ItemCoal(0, count) };
    } else {
        return new Item[0];
    }
}
Also used : Item(cn.nukkit.item.Item) ItemCoal(cn.nukkit.item.ItemCoal) Enchantment(cn.nukkit.item.enchantment.Enchantment)

Aggregations

Item (cn.nukkit.item.Item)1 ItemCoal (cn.nukkit.item.ItemCoal)1 Enchantment (cn.nukkit.item.enchantment.Enchantment)1