How to detect when player walk on stairs, slabs? I used PHP: /** @var Player $player */$player->getLevel()->getBlock(new \pocketmine\math\Vector3($player->x, $player->y - 0.5, $player->z))->getId()); but it's not efficient because it does not detect stairs when you start standing on them, or even slabs & fences. Is there any better way?
PHP: /** @var Player $player */$block = $player->getLevel()->getBlock(new \pocketmine\math\Vector3($player->getX(), $player->getY() - 0.5, $player->getZ()));if($block instanceof \pocketmine\block\Slab){ //code}
You don't understand my question, when I use your code it does not detect when I start walking on stairs, slabs, it detect one block before until you are not fully on the stair,slab
You might want to work with arrays here... You can check multiple blocks arround the player, not just one if that solves you problem.
floor(), intval() or round() the x, the y and the z. EDIT: floor() returns float, so use intval() or round().
Check if the player is collided, then check what the player is collided with. Entity::getBlocksAround() should return the blocks you're looking for, then compare each to the coordinate where the slab is expected to be.