Search in sources :

Example 1 with ItemMelon

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

the class BlockMelon method getDrops.

@Override
public Item[] getDrops(Item item) {
    Random random = new Random();
    int count = 3 + random.nextInt(5);
    Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
    if (fortune != null && fortune.getLevel() >= 1) {
        count += random.nextInt(fortune.getLevel() + 1);
    }
    return new Item[] { new ItemMelon(0, Math.min(9, count)) };
}
Also used : Item(cn.nukkit.item.Item) Random(java.util.Random) Enchantment(cn.nukkit.item.enchantment.Enchantment) ItemMelon(cn.nukkit.item.ItemMelon)

Aggregations

Item (cn.nukkit.item.Item)1 ItemMelon (cn.nukkit.item.ItemMelon)1 Enchantment (cn.nukkit.item.enchantment.Enchantment)1 Random (java.util.Random)1