How can I make the blocks already placed on a map unbreakable? But if they can break blocks that the players have placed. I saw Boi's BedWars code, apparently it uses a variable called $placedBlocks, but nowhere did I find what defines it.
Store the placed blocks in an array and you can have a check for them on break. Or... query if a broken block is breakable by the player?
@minijaham idea is great. If your players can only get certain blocks like wool. Then something like this would work. [I took some idea with the array from minijaham, thanks) PHP: public function onBlockBreak(\pocketmine\event\block\BlockBreakEvent $event){ $level = $event->getPlayer()->getLevel()->getName(); // Gets the player level if($level != "SkyWars"){return;} // Returns the function if the player isn't in SkyWars $allowedBlocks = [35, 121]; // Allow Wool and endstone to be broken if (!in_array($event->getBlock()->getID(), $allowedBlocks)){ $event->setCanceled(); // Cancel the event if the block broken isn't wool }} It basically checks if it's an allowed block to break, if it's allowed it won't cancel the event. I think this is better since there may be more blocks that aren't allowed to be broken.
Maybe it would be to save all the blocks positions as Vector3 in an array and when breaking a block check if the block position as Vector3 is in that array. But, I have not found a function that returns all blocks in a chunk and I also believe that all chunks must be loaded to get their blocks.
Huh? Why would you even do that? Then why don't you just make them unbreakable, not having to check for the block every single time?
I'm doing a BedWars, in this minigame the blocks that come by default on the map cannot be broken, all the others can, that's what I want to achieve...
We've literally spoon-fed you. If you're still not sure how to do it, then just give up. There are plenty of websites where you can learn PHP from.