I tried to make if under the block who player putted a specific block id cancel it, But it doesn't work. This is my code: PHP: public function onPlace(BlockPlaceEvent $event){ $player = $event->getPlayer(); $block = $event->getBlock(); if ($block->getId() == 159 && $block->getDamage() == 14 && $block->getY() > 70) { $player->sendMessage("§cYou can't put blocks here."); $event->setCancelled(true); }} But it doesn't work, I think there is a problem that i think is the $block is what you putted not what under it, Any help?
Assuming your Event Handler is working correctly, either: - The block's id is not 159 - The block's damage is not 14 - The block's y coordinate is less than 70. I don't know what block you placed, what damage it had, or where you placed it, so I can't narrow it down any further. Most times, people's code does work, it just doesn't function as they intended, because of simple logic mistakes.
Thank you I replaced $block = $event->getBlock(); with $block = $event->getBlockAgainst(); and it works!, Solved.