Hi, guys! What is the best way to replace block that player trying to place? I'm trying to make so when some player places ANY block, the DIAMOND_BLOCK will be placed instead. I was trying to hook a BlockPlaceEvent, but i cant find how to change placed block from this event handler. The only way I see is to cancel this BlockPlaceEvent and place manually DIAMOND_BLOCK instead. But may be there is a better way?
BlockPlaceEvent is the best way get the block in that event using: PHP: $block = $event->getBlock(); Than get level of the player that place that block PHP: $level = $event->getPlayer()->getLevel(); The block is already an instanceof Vector3, so: PHP: $level->setBlock($block, pocketmine\block\Block::get($diamond_block_id)); There, simple and easy
Yes, it works, thank you! I thought that may be exist some kind of pre-event for this. Like PlayerPreLoginEvent or PlayerTextPreSendEvent But this way also ok ps: I would mark this thread as "solved" if I knew how to...