检测损坏的块类型 - spigotMC

Detecting what type of block is broken - spigotMC

所以...我正在尝试制作一个插件,当石头 block/cobblestone 方块被破坏时,它有 99% 的几率产卵蠹虫。我知道如何做随机性部分,但我似乎无法编写代码来检查破碎的块是否是石块。有人能帮我吗?确保在上传之前进行测试(因为在我之前的问题中我有 1 个人没有测试)

这是我测试的:

Block block = (Block) e.getBlock();
if (block == Material.STONE){
    block.getWorld().spawnEntity(block.getLocation, EntityType.SILVERFISH); 
    // I do know that blocks can't have an equality to a material, but I already tried as much as I could
}

你很接近。而不是 block == Material.STONE,而是 block.getType() == Material.STONE.