下面列出了org.bukkit.Material#LAPIS_ORE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void scanChunk(Chunk chunk){
for (int x = 0; x < 16; x++){
for (int y = 5; y < 30; y++){
for (int z = 0; z < 16; z++){
Block block = chunk.getBlock(x, y, z);
Material type = block.getType();
if (
type == Material.DIAMOND_ORE ||
type == Material.GOLD_ORE ||
type == Material.LAPIS_ORE
){
Vein vein = new Vein();
vein.process(block);
if (!vein.isConnectedToAir()){
vein.setToStone();
}
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent e) {
ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
if (item.getType() != Material.AIR && item.getAmount() > 0) {
List<ItemStack> drops = new ArrayList<>(e.getBlock().getDrops(item));
int dropAmount = 1;
if (item.getEnchantments().containsKey(Enchantment.LOOT_BONUS_BLOCKS) && !item.getEnchantments().containsKey(Enchantment.SILK_TOUCH)) {
Random random = ThreadLocalRandom.current();
dropAmount = random.nextInt(item.getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS) + 2) - 1;
dropAmount = Math.max(dropAmount, 1);
dropAmount = (e.getBlock().getType() == Material.LAPIS_ORE ? 4 + random.nextInt(5) : 1) * (dropAmount + 1);
}
if (!item.getEnchantments().containsKey(Enchantment.SILK_TOUCH) && MaterialCollections.getAllOres().contains(e.getBlock().getType()) && Talisman.checkFor(e, SlimefunItems.TALISMAN_MINER)) {
for (ItemStack drop : drops) {
if (!drop.getType().isBlock()) {
int amount = Math.max(1, (dropAmount * 2) - drop.getAmount());
e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation(), new CustomItem(drop, amount));
}
}
}
}
}
private int getBonusDropsWithFortune(ItemStack item, Block b) {
int fortune = 1;
if (item != null && item.getEnchantments().containsKey(Enchantment.LOOT_BONUS_BLOCKS) && !item.getEnchantments().containsKey(Enchantment.SILK_TOUCH)) {
Random random = ThreadLocalRandom.current();
int fortuneLevel = item.getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS);
fortune = Math.max(1, random.nextInt(fortuneLevel + 2) - 1);
fortune = (b.getType() == Material.LAPIS_ORE ? 4 + random.nextInt(5) : 1) * (fortune + 1);
}
return fortune;
}