So... I'm trying to make a plugin that when a stone block/cobblestone block is broken, it has a 99% chance for a silverfish to spawn. I know how to do the randomness part, but I can't seem to make the code that checks if the block broken is a stone block. Can someone help me? Make sure to test before you upload (because in my previous question I had 1 person who didn't test)
Here is what I tested:
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
}
You were close. Instead of block == Material.STONE
, do block.getType() == Material.STONE
.