How can I check if a players walks through two block? And if the player walks around these blocks he should get a message
There is a wall with some empty blocks. I want to check if the players walks though the empty blocks. And if he walks around it, he gets a message
Okay, I'm not sure what I am visualizing is right. It would be nice if you can provide an image of what you are meaning.
I tried this to check if the block on the players right is stone. (Didn't work) PHP: $yaw = $player->yaw;$right = $yaw + 180;$x = cos($right * M_PI / 180) * 1 + $player->x;$z = sin($right * M_PI / 180) * 1 + $player->z;if($player->getLevel()->getBlock($player->subtract($x,0,0))->getID() === 1) {
I use this to check if player is in the area PHP: #$pp is player position, $p1 is first point, $p2 is second point public function isInside(Vector3 $pp, Vector3 $p1, Vector3 $p2){ return ((min($p1->getX(),$p2->getX()) <= $pp->getX()) && (max($p1->getX(),$p2->getX()) >= $pp->getX()) && (min($p1->getY(),$p2->getY()) <= $pp->getY()) && (max($p1->getY(),$p2->getY()) >= $pp->getY()) && (min($p1->getZ(),$p2->getZ()) <= $pp->getZ()) && (max($p1->getZ(),$p2->getZ()) >= $pp->getZ())); }
I tried this: But it isn't working correctly PHP: foreach($nrs as $nr) { if($player->getLevel()->getBlock($player->subtract(0,$nr,0))->getID() == 1 && $player->getLevel()->getBlock($player->subtract(0,-$nr,0))->getID() == 1) { $player->sendPopup(TextFormat::GREEN . "You are in a stone room");} $nrs ist an Array with the numbers 1 to 10
I tried this. But it's only true, if the player is in the middle of it. Do u know why? PHP: $in = 0;if($player->getLevel()->getBlock(new Vector3($x, $y + $nr, $z))->getId() == 159) {$in++;}if($player->getLevel()->getBlock(new Vector3($x, $y - $nr, $z))->getId() == 159) {$in++;}if($in == 2) {$player->sendMessage("§aTRUE");} elseif($in == 1) {$player->sendMessage("§cFALSE");}}