From c5a6ef0c640d0e12851105800fc8edfdcc3db930 Mon Sep 17 00:00:00 2001 From: RenzMc Date: Sat, 15 Nov 2025 09:45:26 +0700 Subject: [PATCH] fix error to few arguments in CameraInstructionPacket::create --- src/CameraAPI/CameraHandler.php | 96 +++++----- src/CameraAPI/CameraPresets.php | 92 +++++----- .../Instructions/CameraInstruction.php | 20 +-- .../Instructions/ClearCameraInstruction.php | 54 +++--- .../Instructions/FadeCameraInstruction.php | 60 +++---- .../Instructions/FovCameraInstruction.php | 83 +++++---- .../Instructions/SetCameraInstruction.php | 170 ++++++++++-------- .../Instructions/ShakeCameraInstruction.php | 79 ++++---- .../Instructions/TargetCameraInstruction.php | 58 +++--- 9 files changed, 366 insertions(+), 346 deletions(-) diff --git a/src/CameraAPI/CameraHandler.php b/src/CameraAPI/CameraHandler.php index 739aa77..aadb1f0 100644 --- a/src/CameraAPI/CameraHandler.php +++ b/src/CameraAPI/CameraHandler.php @@ -1,49 +1,47 @@ -plugin))) - { - throw new \Error("Already registered with {$pl->getName()}"); - } - - self::getInstance()->plugin = $plugin; - $interceptor = SimplePacketHandler::createInterceptor($plugin, EventPriority::HIGHEST, false); - $interceptor->interceptIncoming(function (SetLocalPlayerAsInitializedPacket $pk, NetworkSession $target): bool - { - $target->sendDataPacket(CameraPresetsPacket::create(CameraPresets::getAll())); - return true; - }); - } - - public static function isRegistered(): bool - { - return !is_null(self::getInstance()->plugin); - } - - public function getPlugin(): Plugin - { - return $this->plugin; - } -} +plugin))) { + throw new \Error("Already registered with {$pl->getName()}"); + } + + self::getInstance()->plugin = $plugin; + $interceptor = SimplePacketHandler::createInterceptor($plugin, EventPriority::HIGHEST, false); + $interceptor->interceptIncoming(function (SetLocalPlayerAsInitializedPacket $pk, NetworkSession $target): bool { + $target->sendDataPacket(CameraPresetsPacket::create(CameraPresets::getAll())); + return true; + }); + } + + public static function isRegistered(): bool + { + return !is_null(self::getInstance()->plugin); + } + + public function getPlugin(): Plugin + { + return $this->plugin; + } +} diff --git a/src/CameraAPI/CameraPresets.php b/src/CameraAPI/CameraPresets.php index 69e871f..d002095 100644 --- a/src/CameraAPI/CameraPresets.php +++ b/src/CameraAPI/CameraPresets.php @@ -1,46 +1,46 @@ -clear = $clear; - } - - public function setRemoveTarget(bool $removeTarget): void - { - $this->removeTarget = $removeTarget; - } - - public function send(Player $player): void - { - $player->getNetworkSession()->sendDataPacket(CameraInstructionPacket::create(null, $this->clear, null, null, $this->removeTarget, null)); - } -} +clear = $clear; + } + + public function setRemoveTarget(bool $removeTarget): void + { + $this->removeTarget = $removeTarget; + } + + public function send(Player $player): void + { + $player->getNetworkSession()->sendDataPacket(CameraInstructionPacket::create(null, $this->clear, null, null, $this->removeTarget, null, null, null, null)); + } +} diff --git a/src/CameraAPI/Instructions/FadeCameraInstruction.php b/src/CameraAPI/Instructions/FadeCameraInstruction.php index 3fcf2fb..7fac50c 100644 --- a/src/CameraAPI/Instructions/FadeCameraInstruction.php +++ b/src/CameraAPI/Instructions/FadeCameraInstruction.php @@ -1,30 +1,30 @@ -time = new CameraFadeInstructionTime($fadeInTime, $stayInTime, $fadeOutTime); - } - - public function setColor(float $red, float $green, float $blue): void - { - $this->color = new CameraFadeInstructionColor($red, $green, $blue); - } - - public function send(Player $player): void - { - $player->getNetworkSession()->sendDataPacket(CameraInstructionPacket::create(null, null, new CameraFadeInstruction($this->time, $this->color), null, null, null)); - } -} \ No newline at end of file +time = new CameraFadeInstructionTime($fadeInTime, $stayInTime, $fadeOutTime); + } + + public function setColor(float $red, float $green, float $blue): void + { + $this->color = new CameraFadeInstructionColor($red, $green, $blue); + } + + public function send(Player $player): void + { + $player->getNetworkSession()->sendDataPacket(CameraInstructionPacket::create(null, null, new CameraFadeInstruction($this->time, $this->color), null, null, null, null, null, null)); + } +} diff --git a/src/CameraAPI/Instructions/FovCameraInstruction.php b/src/CameraAPI/Instructions/FovCameraInstruction.php index 75a6139..731faa0 100644 --- a/src/CameraAPI/Instructions/FovCameraInstruction.php +++ b/src/CameraAPI/Instructions/FovCameraInstruction.php @@ -1,43 +1,40 @@ -fieldOfView = $fieldOfView; - } - - public function setEaseTime(float $easeTime): void - { - $this->easeTime = $easeTime; - } - - public function setEaseType(float $easeType): void - { - $this->easeType = $easeType; - } - - public function setClear(bool $clear): void - { - $this->clear = $clear; - } - - public function send(Player $player): void - { - $player->getNetworkSession()->sendDataPacket(CameraInstructionPacket::create(null, null, null, null, null, new CameraFovInstruction($this->fieldOfView, $this->easeTime, $this->easeType, $this->clear))); - } -} \ No newline at end of file +fieldOfView = $fieldOfView; + } + + public function setEaseTime(float $easeTime): void + { + $this->easeTime = $easeTime; + } + + public function setEaseType(float $easeType): void + { + $this->easeType = $easeType; + } + + public function setClear(bool $clear): void + { + $this->clear = $clear; + } + + public function send(Player $player): void + { + $player->getNetworkSession()->sendDataPacket(CameraInstructionPacket::create(null, null, null, null, null, new CameraFovInstruction($this->fieldOfView, $this->easeTime, $this->easeType, $this->clear), null, null, null)); + } +} diff --git a/src/CameraAPI/Instructions/SetCameraInstruction.php b/src/CameraAPI/Instructions/SetCameraInstruction.php index 83bd741..8410620 100644 --- a/src/CameraAPI/Instructions/SetCameraInstruction.php +++ b/src/CameraAPI/Instructions/SetCameraInstruction.php @@ -1,72 +1,98 @@ -cameraPreset = $cameraPreset; - } - - public function setEase(int $type, float $duration): void - { - $this->ease = new CameraSetInstructionEase($type, $duration); - } - - public function setCameraPosition(Vector3 $cameraPosition): void - { - $this->cameraPosition = $cameraPosition; - } - - public function setRotation(float $pitch, float $yaw): void - { - $this->rotation = new CameraSetInstructionRotation($pitch, $yaw); - } - - public function setFacingPosition(Vector3 $facingPosition): void - { - $this->facingPosition = $facingPosition; - } - - public function setViewOffset(Vector2 $viewOffset): void - { - $this->viewOffset = $viewOffset; - } - - public function setEntityOffset(Vector3 $entityOffset): void - { - $this->entityOffset = $entityOffset; - } - - public function setIgnoreStartingValuesComponent(bool $ignoreStartingValuesComponent): void - { - $this->ignoreStartingValuesComponent = $ignoreStartingValuesComponent; - } - - public function send(Player $player): void - { - $player->getNetworkSession()->sendDataPacket(CameraInstructionPacket::create(new CameraSetInstruction(array_search($this->cameraPreset, CameraPresets::getAll(), true), $this->ease, $this->cameraPosition, $this->rotation, $this->facingPosition, $this->viewOffset, $this->entityOffset, null, $this->ignoreStartingValuesComponent), null, null, null, null, null)); - } -} +cameraPreset = $cameraPreset; + } + + public function setEase(int $type, float $duration): void + { + $this->ease = new CameraSetInstructionEase($type, $duration); + } + + public function setCameraPosition(Vector3 $cameraPosition): void + { + $this->cameraPosition = $cameraPosition; + } + + public function setRotation(float $pitch, float $yaw): void + { + $this->rotation = new CameraSetInstructionRotation($pitch, $yaw); + } + + public function setFacingPosition(Vector3 $facingPosition): void + { + $this->facingPosition = $facingPosition; + } + + public function setViewOffset(Vector2 $viewOffset): void + { + $this->viewOffset = $viewOffset; + } + + public function setEntityOffset(Vector3 $entityOffset): void + { + $this->entityOffset = $entityOffset; + } + + public function setIgnoreStartingValuesComponent(bool $ignoreStartingValuesComponent): void + { + $this->ignoreStartingValuesComponent = $ignoreStartingValuesComponent; + } + + public function send(Player $player): void + { + $presetIndex = array_search($this->cameraPreset, CameraPresets::getAll(), true); + + $cameraSetInstruction = new CameraSetInstruction( + $presetIndex, + $this->ease, + $this->cameraPosition, + $this->rotation, + $this->facingPosition, + $this->viewOffset, + $this->entityOffset, + null, + $this->ignoreStartingValuesComponent + ); + + $packet = CameraInstructionPacket::create( + $cameraSetInstruction, + null, + null, + null, + null, + null, + null, + null, + null + ); + + $player->getNetworkSession()->sendDataPacket($packet); + } +} diff --git a/src/CameraAPI/Instructions/ShakeCameraInstruction.php b/src/CameraAPI/Instructions/ShakeCameraInstruction.php index d9d13b5..40ab9d9 100644 --- a/src/CameraAPI/Instructions/ShakeCameraInstruction.php +++ b/src/CameraAPI/Instructions/ShakeCameraInstruction.php @@ -1,40 +1,39 @@ -intensity = $intensity; - } - - public function setDuration(float $duration): void - { - $this->duration = $duration; - } - - public function setShakeType(int $shakeType): void - { - $this->shakeType = $shakeType; - } - - public function setShakeAction(int $shakeAction): void - { - $this->shakeAction = $shakeAction; - } - - public function send(Player $player): void - { - $player->getNetworkSession()->sendDataPacket(CameraShakePacket::create($this->intensity, $this->duration, $this->shakeType, $this->shakeAction)); - } -} +intensity = $intensity; + } + + public function setDuration(float $duration): void + { + $this->duration = $duration; + } + + public function setShakeType(int $shakeType): void + { + $this->shakeType = $shakeType; + } + + public function setShakeAction(int $shakeAction): void + { + $this->shakeAction = $shakeAction; + } + + public function send(Player $player): void + { + $player->getNetworkSession()->sendDataPacket(CameraShakePacket::create($this->intensity, $this->duration, $this->shakeType, $this->shakeAction)); + } +} diff --git a/src/CameraAPI/Instructions/TargetCameraInstruction.php b/src/CameraAPI/Instructions/TargetCameraInstruction.php index b9e78e8..7eff706 100644 --- a/src/CameraAPI/Instructions/TargetCameraInstruction.php +++ b/src/CameraAPI/Instructions/TargetCameraInstruction.php @@ -1,29 +1,29 @@ -targetCenterOffset = $targetCenterOffset; - } - - public function setActorUniqueId(int $actorUniqueId): void - { - $this->actorUniqueId = $actorUniqueId; - } - - public function send(Player $player): void - { - $player->getNetworkSession()->sendDataPacket(CameraInstructionPacket::create(null, null, null, new CameraTargetInstruction($this->targetCenterOffset, $this->actorUniqueId), null, null)); - } -} \ No newline at end of file +targetCenterOffset = $targetCenterOffset; + } + + public function setActorUniqueId(int $actorUniqueId): void + { + $this->actorUniqueId = $actorUniqueId; + } + + public function send(Player $player): void + { + $player->getNetworkSession()->sendDataPacket(CameraInstructionPacket::create(null, null, null, new CameraTargetInstruction($this->targetCenterOffset, $this->actorUniqueId), null, null, null, null, null)); + } +}