player = $player; $this->session = $session; } public function setUp() : void{ $this->session->sendDataPacket(RespawnPacket::create( $this->player->getOffsetPosition($this->player->getSpawn()), RespawnPacket::SEARCHING_FOR_SPAWN, $this->player->getId() )); } public function handlePlayerAction(PlayerActionPacket $packet) : bool{ switch($packet->action){ case PlayerActionPacket::ACTION_RESPAWN: $this->player->respawn(); return true; case PlayerActionPacket::ACTION_DIMENSION_CHANGE_REQUEST: //TODO: players send this when they die in another dimension break; } return false; } public function handleRespawn(RespawnPacket $packet) : bool{ if($packet->respawnState === RespawnPacket::CLIENT_READY_TO_SPAWN){ $this->session->sendDataPacket(RespawnPacket::create( $this->player->getOffsetPosition($this->player->getSpawn()), RespawnPacket::READY_TO_SPAWN, $this->player->getId() )); return true; } return false; } }