How can I check if a player is near a sign with "knockback" on the first line an give the player knockback?
PHP: const RADIUS_SQ = 16;/** @var Player $player */foreach($player->getLevel()->getTiles() as $tile){ if($tile instanceof Sign){ if($player->distanceSquared($tile) <= self::RADIUS_SQ){ $player->setMotion($tile->add($player)->normalize()->multiply(4)); } }}
This isn't working. Nothing happens and no errors PHP: public function onPlayerMove(PlayerMoveEvent $event) {$player = $event->getPlayer();//const RADIUS_SQ = 16;foreach($player->getLevel()->getTiles() as $tile){ if($tile instanceof Sign){ if($player->distanceSquared($tile) <= 3){ $player->sendMessage("Test"); $player->setMotion($tile->add($player)->normalize()->multiply(4)); } }}}