Search in sources :

Example 1 with ItemDye

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

the class BlockOreLapis method getDrops.

@Override
public Item[] getDrops(Item item) {
    if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_STONE) {
        int count = 4 + ThreadLocalRandom.current().nextInt(5);
        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 ItemDye(4, new Random().nextInt(4) + 4) };
    } else {
        return new Item[0];
    }
}
Also used : Item(cn.nukkit.item.Item) NukkitRandom(cn.nukkit.math.NukkitRandom) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Random(java.util.Random) ItemDye(cn.nukkit.item.ItemDye) Enchantment(cn.nukkit.item.enchantment.Enchantment)

Aggregations

Item (cn.nukkit.item.Item)1 ItemDye (cn.nukkit.item.ItemDye)1 Enchantment (cn.nukkit.item.enchantment.Enchantment)1 NukkitRandom (cn.nukkit.math.NukkitRandom)1 Random (java.util.Random)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1