How add stopping creating obsidian to block bedrock? PHP: <?phpnamespace dragonflex;use pocketmine\plugin\PluginBase as P;use pocketmine\event\Listener as L;use pocketmine\utils\TextFormat;use pocketmine\utils\MainLogger;use pocketmine\block\Air;use pocketmine\Server;use pocketmine\event\block\BlockPlaceEvent as BPL;use pocketmine\block\Block;use pocketmine\math\Vector3;use pocketmine\item\Item;class Main extends P implements L{ public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this,$this); $this->saveDefaultConfig(); $this->getServer()->getLogger()->info(TextFormat::GREEN."[Boyfarner] wlaczony!"); } public function onPlace(BPL $e){ $player = $e->getPlayer(); $blok = $e->getBlock(); $gracz = $e->getPlayer()->getName(); if($e->getBlock()->getId() == 121){ $this->getServer()->$gracz->getLevel()->setBlock(new Vector3($blok->getFloorX(), $blok->getFloorY()-80, $blok->getFloorZ()), new Obsidian()); $e->setCancelled(); } }}
BPE is only called when a player places the block. So your code will not replace all bedrock in the world. Only the bedrock placed by a player. I am going to assume you know that, and continue with what I see wrong with your code. Instead of checking if the block ID == the ID number, use Item::ITEM_NAME to get the ID. This provides use in the event item and block IDs are changed. You used: PHP: $gracz = $e->getPlayer()->getName();//later in your code, you used: $this->getServer()->$gracz->getLevel(); //... There are so many things wrong with this. In your case, you do not need the player's name at all, and you certainly can't call any events with that name. You don't need to get the server either, because it provides no use in this case. You could instead use: PHP: $e->getPlayer->getLevel()->setBlock(new Vector3($blok->getFloorX(), $blok->getFloorY()-80 /*Why - 80? */, $blok->getFloorZ()), new Obsidian());/*add use statement for Obsidian Block, because otherwise you will get an error.*//*You may not even need to getFloorX(), getFloorY(), etc. I am not sure though, so I won't go into that. */