How would I know if I should add x or z from getDirection? Or other functions? I am trying to setBlock every air block in front of your face
replace Player:: with the player. do you mean PHP: Player::getLevel()->setBlock(new Vector3(Player::getX()+1, Player::getY()+1, Player::getZ()));
How would I do it in a blocks perspective? I have a block (dirt) and want to set 2 blocks towards the player looking at it.
Something like this? PHP: $x = $player->x; $y = $player->y; $z = $player->z; switch($player->getDirection()){ case 0: $x += 2; break; case 1: $z += 2; break; case 2: $x -= 2; break; case 3: $z -= 2; break; } $level->setBlock(new Vector3($x,$y,$z),Block::get(0));
But I want in a blocks perspective? So I want when a player is looking at a 2 block high pillar, the pillar extends (setBlock) towards the player.
Maybe you mean PHP: $x = $player->x;$y = $player->y;$z = $player->z;switch($player->getDirection()){case 0: $x -= 1; break;case 1: $z -= 1; break;case 2: $x += 1; break;case 3: $z += 1; break;}$blocks = $player->getLineOfSight($distance);foreach($blocks as $b)$level->setBlock(new Vector3($x,$y,$z),Block::get(1));
Not sure what exactly you are asking about, but maybe you mean these: https://github.com/PocketMine/PocketMine-MP/blob/master/src/pocketmine/math/Vector3.php#L26