PHP: function onMove(PlayerMoveEvent $ev){ $player = $ev->getPlayer(); if($player->getLevel()->getBlock(new Vector3($player->x,$player->y,$player->z)->getId() === Block::STONE){ $this->getServer()->dispatchCommand($player,"say Player on the Stone");}
Won't work as it will return block from player's feet position. And there is no need to construct new Vector3 instance as Player already extends it. PHP: /** * @param \pocketmine\event\player\PlayerMoveEvent $e * @priority MONITOR * @ignoreCancelled false */public function onPlayerMove(PlayerMoveEvent $e){ if($e->getPlayer()->getLevel()->getBlockIdAt($e->getPlayer()->subtract(0, 1)) === Block::STONE){ // Server::dispatchCommand() is a bad practice }}
Don't use PlayerMoveEvent, it will check every player's movement, which is more work for the server. Use RepeatingTask to check if somebody is standing on stone.
Well that's exactly what I do when creating plugins (SpecialBlock) but as he asked me for simple code, I gave him one.
Now i done it right. But now it don't find the Main class. What i have to chance? In the main.php? or where.
Notice: This is PocketMine forum. Following issues found: Plugin hasn't registered any listener Functions onEnable(), onLoad() and onDisable() not found (It's not necessary but it's good to use them e.g. register listener onEnable()) Plugin doesn't contain any valid listener class ClassNotFoundException on line 13 (Solution: Import \pocketmine\block\Block) Syntax error on line 4 Unused import on line 5, 6, 7, 8. (plugin.yml) Main class not found: You have to use backslash (\) instead of forward (/) for namespaces Main class' file has to be same as class' name And show us your project tree.