I have this code: PHP: public function BlockPlace(BlockPlaceEvent $event){ { $player = $event->getPlayer(); if($player->isOp()){ $level = $this->getServer()->getDefaultLevel(); $startingx = 31; $endingx = 52; $startingy = 122; $endingy = 133; $startingz = -886; $endingz = -903; for($x = $startingx; $x < $endingx; $x++){ for($z = $startingz; $z < $endingz; $z++){ for($y = $startingy; $y < $endingy; $y++){ if($level->getBlock(new Vector3($x, $y, $z))->getId() === 5){ $level->setBlock(new Vector3($x, $y, $z), Block::get(Block::AIR)); so yeah you can see what I'm trying to do but when a player places a block nothing happens to the wood blocks in that selected area. I don't even get an error message in the console
Might it be because all the position have nothing to do with the actual event. I mean I haven't used $event->getBlock(); anywhere
Please also note that your code is extremely laggy. I could DoS your server easily by breaking glass walls anywhere.
Yes I know I've done this as a test. I plan to add this to a game and it will have nothing to do with placing a block to make it work. It'll work if the game timer is at 0 and I think setting block update to 'false, false' will avoid lag when setting block..?
Nothing other than deleting all executing code prevents lag. You only reduce the lag, but remember there is still some of it.
PHP: $this->getServer()->getPluginManager()->registerEvents($this, $this); That will work if the function is in your main class.