Avoid using PlayerMoveEvent whenever you can. Task can accomplish this task as good. Make sure, You're doing the checks only when necessary (specific level, area and/or specific players etc.)
What's the source of this information? Well of course, this depends on per situation basis. I'm not sure if calling twice per tick is necessary in this situation.
PlayerMoveEvent would give you the most precise results. A task, assuming it's delay > 1 tick is only going to skip checking the block below. F.e, if you sprint over a grass block in 1 second and the task has a delay of 20 ticks, the task won't catch it. Any way you do it, it's going to result in many unnecessary block check calls. At the least, the event method won't be doing block below calls when player isn't moving. Doing a mere block below check in PlayerMoveEvent is not heavy, unless ofcourse you're doing something more than just that. Several surrounding block checks happen anyway when mobs and dropped items move.
i will use Code: $player = $player #you get at everywhere; $block = $player->getLevel()->getBlock(new Vector3($player->x, $player->y - 0.5, $player->z)); return $block->getId(); #block id
Wow, I was not expecting as much response, I already know the move event but it seems to be quite overloaded that's why I said to myself there may be a way to do it via colision with a block or whatever. If someone has more info I am a taker
no, if you use this code, it will get the block that the leg is inside which is air ,not the block under
i have just noticed that there is no getPos() , it must be getPostion() or sth else and subtract() is already has a minus symbol on it ,and it was required 3 parameters not 2 https://github.com/pmmp/Math/blob/master/src/Vector3.php#L124-L126 so it also must be subtract(0,0.5,0); PHP: $player->asVector3()->substract(0,0.5,0); Let me make this clear, i didnt want to mock you, you just was wrong and still wrong again , you was so bad
Easy way: 1. check under block of player onMovement 2. getBlock($player->x, $player->y - 0.7. $player->z); i used 0.7 its better than 0.5, when player jump on movment it has bug with 0.5 3. if ($block->getId() == Block::GRASS_BLOCK) { //do something or RUN CODE } 4. alway use this code to if block is air dont run code or cmd. if ($block->getId !== Block::AIR) { //now if isnt block under Air } 5. Every thing is done for checking player under block