Im makeing a plugin that if you have a specific block and place it it will spawn 10 cobble stone block under the block. How would I do the getBlock()->getLevel()->setBlock($block getX(-1)); then another getBlock()->getLevel()->setBlock($block getX(-2)); is their anything wrong with this code
To do this, use: PHP: public function onPlace(BlockPlaceEvent $event) { $block = $event->getBlock(); if($block->getId() === Block::GLASS) { // if placed block is glass $level = $block->getLevel(); for($i = $block->getY() - 1; $i >= $block->getY() - 10; $i--) { // goes down 10 blocks $level->setBlock(new Vector3($block->getX(), $i, $block->getZ()), Block::get(4)); // places cobblestone } }} It will place 10 cobblestone below the placed bedrock, for example.