From 84f8be2fb66ad3c019138baaada480dbdf240794 Mon Sep 17 00:00:00 2001 From: DaisukeDaisuke <17798680+DaisukeDaisuke@users.noreply.github.com> Date: Tue, 15 Jul 2025 14:25:23 +0900 Subject: [PATCH 1/9] fix for 1.21.93 --- README.md | 104 ++++++++++++++--- plugin.yml | 6 + src/muqsit/libcamera/CameraInstruction.php | 12 +- src/muqsit/libcamera/libcamera.php | 129 +++++++++++++++++++-- src/muqsit/libcamera/libcameramain.php | 15 +++ 5 files changed, 241 insertions(+), 25 deletions(-) create mode 100644 plugin.yml create mode 100644 src/muqsit/libcamera/libcameramain.php diff --git a/README.md b/README.md index 685f06d..2b48782 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,14 @@ To send instructions to the camera, use the following code: - Set +
+ See demo + +https://github.com/user-attachments/assets/338e4b84-1ded-4424-9ffb-6e94298bc53c + +
+ + ```php use muqsit\libcamera\libcamera; use muqsit\libcamera\CameraInstruction; @@ -74,10 +82,10 @@ if($player instanceof Player && $player->isOnline()){ CameraSetInstructionEaseType::IN_OUT_CUBIC, (float) 5.0 // duration (sec) ), - camera_pos: null, + camera_pos: $player->getPosition()->add(0.0, $player->getEyeHeight(), 0.0), //Without it, the camera will teleport into subspace rot: new CameraSetInstructionRotation( - (float)20.0, //pitch - (float)180.0 //yaw + (float)$player->getLocation()->getPitch(), //pitch + (float)$player->getLocation()->getYaw() //yaw ), facing_pos: null )->send($player); @@ -108,24 +116,88 @@ if($player instanceof Player && $player->isOnline()){ - Target +After setting the camera to free mode, you need to explicitly assign a target. +This allows the camera to visually track a specific entity. +Unlike SetActorLinkPacket, it does not follow the entity automatically. + +
+ See demo + +https://github.com/user-attachments/assets/38cd6bf1-f666-4635-870b-2d51b12bfa3f + +
+ ```php -use muqsit\libcamera\libcamera; +use pocketmine\event\player\PlayerInteractEvent; use muqsit\libcamera\CameraInstruction; -use pocketmine\network\mcpe\protocol\types\camera\CameraTargetInstruction; +use pocketmine\entity\Zombie; +use muqsit\libcamera\libcamera; +use pocketmine\network\mcpe\protocol\types\camera\CameraSetInstructionEase; +use pocketmine\network\mcpe\protocol\types\camera\CameraSetInstructionEaseType; +use pocketmine\network\mcpe\protocol\types\camera\CameraSetInstructionRotation; use pocketmine\math\Vector3; -use pocketmine\player\Player; // ... -if($player instanceof Player && $player->isOnline()){ - /** - * @phpstan-param Vector3|null $targetCenterOffset - * @phpstan-param int $actorUniqueId - */ - CameraInstruction::target( - targetCenterOffset: Vector3::zero(), // no offset - actorUniqueId: $player->getId() // for example target the player - )->send($player); -} + + /** @var array */ + private $set = []; + + public function ina(PlayerInteractEvent $event) : void{ + $player = $event->getPlayer(); + if(!$player->isSneaking()){ + return; + } + + //Removes camera tracking. Note that target and free cameras are managed separately. + if(isset($this->set[$player->getName()])){ + CameraInstruction::removeTarget()->send($player); + CameraInstruction::clear()->send($player); + unset($this->set[$player->getName()]); + return; + } + + //Find the most different zombie entities + $nearest = null; + $nearestDistance = PHP_INT_MAX; + foreach($player->getWorld()->getEntities() as $entity){ + if($entity instanceof Zombie){ + $distance = $player->getPosition()->distance($entity->getPosition()); + if($nearestDistance >= $distance){ + $nearest = $entity; + $nearestDistance = $distance; + } + } + } + + if($nearest === null){ + $player->sendMessage("No Zombie"); + return; + } + + // + CameraInstruction::set( + preset: libcamera::getPresetRegistry()->registered["target"], + ease: new CameraSetInstructionEase( + CameraSetInstructionEaseType::IN_OUT_CUBIC, + (float) 5.0 // duration (sec) + ), + camera_pos: $player->getPosition()->add(0, $player->getEyeHeight(), 0), + rot: new CameraSetInstructionRotation( + (float) $player->getLocation()->getPitch(), //pitch + (float) $player->getLocation()->getYaw() //yaw + ), + facing_pos: null + )->send($player); + + //To use CameraInstruction::target you first need to make it a free camera. + CameraInstruction::target( + targetCenterOffset: Vector3::zero(), // no offset + actorUniqueId: $nearest->getId() // for example target the player + )->send($player); + + //Manages which packets have been sent + $this->set[$player->getName()] = true; + } ``` - Remove Target diff --git a/plugin.yml b/plugin.yml new file mode 100644 index 0000000..9baad1d --- /dev/null +++ b/plugin.yml @@ -0,0 +1,6 @@ +--- +name: libCamera +version: 0.0.1 +main: muqsit\libcamera\libcameramain +api: 5.31.0 +... diff --git a/src/muqsit/libcamera/CameraInstruction.php b/src/muqsit/libcamera/CameraInstruction.php index dcb5933..2d88f21 100644 --- a/src/muqsit/libcamera/CameraInstruction.php +++ b/src/muqsit/libcamera/CameraInstruction.php @@ -37,7 +37,17 @@ public static function set( ?Vector3 $facing_pos = null ) : self{ $preset_id = libcamera::getPresetRegistry()->network_ids[spl_object_id($preset)]; - $instruction = new CameraSetInstruction($preset_id, $ease, $camera_pos, $rot, $facing_pos, null, null, null); + $instruction = new CameraSetInstruction( + preset: $preset_id, + ease: $ease, + cameraPosition: $camera_pos, + rotation: $rot, + facingPosition: $facing_pos, + viewOffset: null, + entityOffset: null, + default: null, + ignoreStartingValuesComponent: false + ); return new self([[$instruction, null, null, null]]); } diff --git a/src/muqsit/libcamera/libcamera.php b/src/muqsit/libcamera/libcamera.php index 841cfa3..c28c634 100644 --- a/src/muqsit/libcamera/libcamera.php +++ b/src/muqsit/libcamera/libcamera.php @@ -32,11 +32,126 @@ public static function isRegistered(): bool{ public static function register(Plugin $plugin) : void{ !self::$registered || throw new BadMethodCallException("Tried to registered an already existing libcamera instance"); $preset_registry = new CameraPresetRegistry([ - "free" => new CameraPreset("minecraft:free", "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_CAMERA, false, false, null), - "first_person" => new CameraPreset("minecraft:first_person", "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_PLAYER, false, false, null), - "third_person" => new CameraPreset("minecraft:third_person", "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_PLAYER, false, false, null), - "third_person_front" => new CameraPreset("minecraft:third_person_front", "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_PLAYER, false, false, null), - "target" => new CameraPreset("minecraft:target", "minecraft:free", null, null, null, null, null, 0.0, true, new Vector2(0.0, 360.0), new Vector2(0.0, 180.0), true, 50.0, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_CAMERA, false, false, null) + "free" => new CameraPreset( + name: "minecraft:free", + parent: "", + xPosition: null, + yPosition: null, + zPosition: null, + pitch: null, + yaw: null, + rotationSpeed: null, + snapToTarget: null, + horizontalRotationLimit: null, + verticalRotationLimit: null, + continueTargeting: null, + blockListeningRadius: null, + viewOffset: null, + entityOffset: null, + radius: null, + yawLimitMin: null, + yawLimitMax: null, + audioListenerType: CameraPreset::AUDIO_LISTENER_TYPE_CAMERA, + playerEffects: false, + aimAssist: null, + controlScheme: null + ), + "first_person" => new CameraPreset( + name: "minecraft:first_person", + parent: "", + xPosition: null, + yPosition: null, + zPosition: null, + pitch: null, + yaw: null, + rotationSpeed: null, + snapToTarget: null, + horizontalRotationLimit: null, + verticalRotationLimit: null, + continueTargeting: null, + blockListeningRadius: null, + viewOffset: null, + entityOffset: null, + radius: null, + yawLimitMin: null, + yawLimitMax: null, + audioListenerType: CameraPreset::AUDIO_LISTENER_TYPE_PLAYER, + playerEffects: false, + aimAssist: null, + controlScheme: null + ), + "third_person" => new CameraPreset( + name: "minecraft:third_person", + parent: "", + xPosition: null, + yPosition: null, + zPosition: null, + pitch: null, + yaw: null, + rotationSpeed: null, + snapToTarget: null, + horizontalRotationLimit: null, + verticalRotationLimit: null, + continueTargeting: null, + blockListeningRadius: null, + viewOffset: null, + entityOffset: null, + radius: null, + yawLimitMin: null, + yawLimitMax: null, + audioListenerType: CameraPreset::AUDIO_LISTENER_TYPE_PLAYER, + playerEffects: false, + aimAssist: null, + controlScheme: null + ), + "third_person_front" => new CameraPreset( + name: "minecraft:third_person_front", + parent: "", + xPosition: null, + yPosition: null, + zPosition: null, + pitch: null, + yaw: null, + rotationSpeed: null, + snapToTarget: null, + horizontalRotationLimit: null, + verticalRotationLimit: null, + continueTargeting: null, + blockListeningRadius: null, + viewOffset: null, + entityOffset: null, + radius: null, + yawLimitMin: null, + yawLimitMax: null, + audioListenerType: CameraPreset::AUDIO_LISTENER_TYPE_PLAYER, + playerEffects: false, + aimAssist: null, + controlScheme: null + ), + "target" => new CameraPreset( + name: "minecraft:target", + parent: "minecraft:free", + xPosition: null, + yPosition: null, + zPosition: null, + pitch: null, + yaw: null, + rotationSpeed: 0.0, + snapToTarget: true, + horizontalRotationLimit: new Vector2(0.0, 360.0), + verticalRotationLimit: new Vector2(0.0, 180.0), + continueTargeting: true, + blockListeningRadius: 50.0, + viewOffset: null, + entityOffset: null, + radius: null, + yawLimitMin: null, + yawLimitMax: null, + audioListenerType: CameraPreset::AUDIO_LISTENER_TYPE_CAMERA, + playerEffects: false, + aimAssist: null, + controlScheme: null + ) ]); $packet = CameraPresetsPacket::create(array_values($preset_registry->registered)); Server::getInstance()->getPluginManager()->registerEvent(DataPacketReceiveEvent::class, function(DataPacketReceiveEvent $event) use($packet) : void{ @@ -48,9 +163,7 @@ public static function register(Plugin $plugin) : void{ foreach($event->getPackets() as $packet){ if($packet instanceof StartGamePacket){ $experiments = $packet->levelSettings->experiments->getExperiments(); - $experiments["focus_target_camera"] = true; - $experiments["third_person_cameras"] = true; - $experiments["cameras"] = true; + $experiments["experimental_creator_camera"] = true;//It seems to work without it. $packet->levelSettings->experiments = new Experiments($experiments, true); } } diff --git a/src/muqsit/libcamera/libcameramain.php b/src/muqsit/libcamera/libcameramain.php new file mode 100644 index 0000000..8956414 --- /dev/null +++ b/src/muqsit/libcamera/libcameramain.php @@ -0,0 +1,15 @@ + Date: Tue, 15 Jul 2025 14:32:24 +0900 Subject: [PATCH 2/9] update README.md --- README.md | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2b48782..7663b31 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,13 @@ if($player instanceof Player && $player->isOnline()){ - Fade +
+ See demo + +https://github.com/user-attachments/assets/01bfc489-16bd-4424-aad0-32abb81d7517 + +
+ ```php use muqsit\libcamera\libcamera; use muqsit\libcamera\CameraInstruction; @@ -103,6 +110,13 @@ use pocketmine\player\Player; // ... if($player instanceof Player && $player->isOnline()){ + $fadeInTime = 5; + $stayTime = 2; + $fadeOutTime = 2; + $r = 0; + $g = 0; + $b = 0; + /** * @phpstan-param CameraFadeInstructionColor|null $color * @phpstan-param CameraFadeInstructionTime|null $time @@ -148,7 +162,7 @@ use pocketmine\math\Vector3; return; } - //Removes camera tracking. Note that target and free cameras are managed separately. + //Removes camera tracking. Note that target and free cameras are managed separately. if(isset($this->set[$player->getName()])){ CameraInstruction::removeTarget()->send($player); CameraInstruction::clear()->send($player); @@ -156,7 +170,7 @@ use pocketmine\math\Vector3; return; } - //Find the most different zombie entities + //Find the most different zombie entities $nearest = null; $nearestDistance = PHP_INT_MAX; foreach($player->getWorld()->getEntities() as $entity){ @@ -174,7 +188,7 @@ use pocketmine\math\Vector3; return; } - // + // CameraInstruction::set( preset: libcamera::getPresetRegistry()->registered["target"], ease: new CameraSetInstructionEase( @@ -189,13 +203,13 @@ use pocketmine\math\Vector3; facing_pos: null )->send($player); - //To use CameraInstruction::target you first need to make it a free camera. + //To use CameraInstruction::target you first need to make it a free camera. CameraInstruction::target( targetCenterOffset: Vector3::zero(), // no offset actorUniqueId: $nearest->getId() // for example target the player )->send($player); - //Manages which packets have been sent + //Manages which packets have been sent $this->set[$player->getName()] = true; } ``` From b14159771fbfdfb7c55894ce78087c3329c69e88 Mon Sep 17 00:00:00 2001 From: DaisukeDaisuke <17798680+DaisukeDaisuke@users.noreply.github.com> Date: Wed, 16 Jul 2025 09:54:47 +0900 Subject: [PATCH 3/9] This is not a plugin --- README.md | 4 ++-- plugin.yml | 6 ------ src/muqsit/libcamera/libcameramain.php | 15 --------------- 3 files changed, 2 insertions(+), 23 deletions(-) delete mode 100644 plugin.yml delete mode 100644 src/muqsit/libcamera/libcameramain.php diff --git a/README.md b/README.md index 7663b31..3b705e5 100644 --- a/README.md +++ b/README.md @@ -84,8 +84,8 @@ if($player instanceof Player && $player->isOnline()){ ), camera_pos: $player->getPosition()->add(0.0, $player->getEyeHeight(), 0.0), //Without it, the camera will teleport into subspace rot: new CameraSetInstructionRotation( - (float)$player->getLocation()->getPitch(), //pitch - (float)$player->getLocation()->getYaw() //yaw + (float)20.0, //pitch + (float)180.0 //yaw ), facing_pos: null )->send($player); diff --git a/plugin.yml b/plugin.yml deleted file mode 100644 index 9baad1d..0000000 --- a/plugin.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -name: libCamera -version: 0.0.1 -main: muqsit\libcamera\libcameramain -api: 5.31.0 -... diff --git a/src/muqsit/libcamera/libcameramain.php b/src/muqsit/libcamera/libcameramain.php deleted file mode 100644 index 8956414..0000000 --- a/src/muqsit/libcamera/libcameramain.php +++ /dev/null @@ -1,15 +0,0 @@ - Date: Wed, 16 Jul 2025 10:02:51 +0900 Subject: [PATCH 4/9] fixed // --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 3b705e5..8339860 100644 --- a/README.md +++ b/README.md @@ -188,7 +188,6 @@ use pocketmine\math\Vector3; return; } - // CameraInstruction::set( preset: libcamera::getPresetRegistry()->registered["target"], ease: new CameraSetInstructionEase( From aa948f8cbee85c6ad697026a69649fe14e409242 Mon Sep 17 00:00:00 2001 From: DaisukeDaisuke <17798680+DaisukeDaisuke@users.noreply.github.com> Date: Wed, 6 Aug 2025 08:55:24 +0900 Subject: [PATCH 5/9] Useless changes --- README.md | 113 +++--------------- src/muqsit/libcamera/CameraInstruction.php | 12 +- src/muqsit/libcamera/libcamera.php | 126 +-------------------- 3 files changed, 21 insertions(+), 230 deletions(-) diff --git a/README.md b/README.md index 8339860..ce70fea 100644 --- a/README.md +++ b/README.md @@ -49,14 +49,6 @@ To send instructions to the camera, use the following code: - Set -
- See demo - -https://github.com/user-attachments/assets/338e4b84-1ded-4424-9ffb-6e94298bc53c - -
- - ```php use muqsit\libcamera\libcamera; use muqsit\libcamera\CameraInstruction; @@ -82,7 +74,7 @@ if($player instanceof Player && $player->isOnline()){ CameraSetInstructionEaseType::IN_OUT_CUBIC, (float) 5.0 // duration (sec) ), - camera_pos: $player->getPosition()->add(0.0, $player->getEyeHeight(), 0.0), //Without it, the camera will teleport into subspace + camera_pos: null, //Without it, the camera will teleport into subspace rot: new CameraSetInstructionRotation( (float)20.0, //pitch (float)180.0 //yaw @@ -94,13 +86,6 @@ if($player instanceof Player && $player->isOnline()){ - Fade -
- See demo - -https://github.com/user-attachments/assets/01bfc489-16bd-4424-aad0-32abb81d7517 - -
- ```php use muqsit\libcamera\libcamera; use muqsit\libcamera\CameraInstruction; @@ -110,13 +95,6 @@ use pocketmine\player\Player; // ... if($player instanceof Player && $player->isOnline()){ - $fadeInTime = 5; - $stayTime = 2; - $fadeOutTime = 2; - $r = 0; - $g = 0; - $b = 0; - /** * @phpstan-param CameraFadeInstructionColor|null $color * @phpstan-param CameraFadeInstructionTime|null $time @@ -130,87 +108,24 @@ if($player instanceof Player && $player->isOnline()){ - Target -After setting the camera to free mode, you need to explicitly assign a target. -This allows the camera to visually track a specific entity. -Unlike SetActorLinkPacket, it does not follow the entity automatically. - -
- See demo - -https://github.com/user-attachments/assets/38cd6bf1-f666-4635-870b-2d51b12bfa3f - -
- ```php -use pocketmine\event\player\PlayerInteractEvent; -use muqsit\libcamera\CameraInstruction; -use pocketmine\entity\Zombie; use muqsit\libcamera\libcamera; -use pocketmine\network\mcpe\protocol\types\camera\CameraSetInstructionEase; -use pocketmine\network\mcpe\protocol\types\camera\CameraSetInstructionEaseType; -use pocketmine\network\mcpe\protocol\types\camera\CameraSetInstructionRotation; +use muqsit\libcamera\CameraInstruction; +use pocketmine\network\mcpe\protocol\types\camera\CameraTargetInstruction; use pocketmine\math\Vector3; +use pocketmine\player\Player; // ... - - /** @var array */ - private $set = []; - - public function ina(PlayerInteractEvent $event) : void{ - $player = $event->getPlayer(); - if(!$player->isSneaking()){ - return; - } - - //Removes camera tracking. Note that target and free cameras are managed separately. - if(isset($this->set[$player->getName()])){ - CameraInstruction::removeTarget()->send($player); - CameraInstruction::clear()->send($player); - unset($this->set[$player->getName()]); - return; - } - - //Find the most different zombie entities - $nearest = null; - $nearestDistance = PHP_INT_MAX; - foreach($player->getWorld()->getEntities() as $entity){ - if($entity instanceof Zombie){ - $distance = $player->getPosition()->distance($entity->getPosition()); - if($nearestDistance >= $distance){ - $nearest = $entity; - $nearestDistance = $distance; - } - } - } - - if($nearest === null){ - $player->sendMessage("No Zombie"); - return; - } - - CameraInstruction::set( - preset: libcamera::getPresetRegistry()->registered["target"], - ease: new CameraSetInstructionEase( - CameraSetInstructionEaseType::IN_OUT_CUBIC, - (float) 5.0 // duration (sec) - ), - camera_pos: $player->getPosition()->add(0, $player->getEyeHeight(), 0), - rot: new CameraSetInstructionRotation( - (float) $player->getLocation()->getPitch(), //pitch - (float) $player->getLocation()->getYaw() //yaw - ), - facing_pos: null - )->send($player); - - //To use CameraInstruction::target you first need to make it a free camera. - CameraInstruction::target( - targetCenterOffset: Vector3::zero(), // no offset - actorUniqueId: $nearest->getId() // for example target the player - )->send($player); - - //Manages which packets have been sent - $this->set[$player->getName()] = true; - } +if($player instanceof Player && $player->isOnline()){ + /** + * @phpstan-param Vector3|null $targetCenterOffset + * @phpstan-param int $actorUniqueId + */ + CameraInstruction::target( + targetCenterOffset: Vector3::zero(), // no offset + actorUniqueId: $player->getId() // for example target the player + )->send($player); +} ``` - Remove Target diff --git a/src/muqsit/libcamera/CameraInstruction.php b/src/muqsit/libcamera/CameraInstruction.php index 2d88f21..89bc1a2 100644 --- a/src/muqsit/libcamera/CameraInstruction.php +++ b/src/muqsit/libcamera/CameraInstruction.php @@ -37,17 +37,7 @@ public static function set( ?Vector3 $facing_pos = null ) : self{ $preset_id = libcamera::getPresetRegistry()->network_ids[spl_object_id($preset)]; - $instruction = new CameraSetInstruction( - preset: $preset_id, - ease: $ease, - cameraPosition: $camera_pos, - rotation: $rot, - facingPosition: $facing_pos, - viewOffset: null, - entityOffset: null, - default: null, - ignoreStartingValuesComponent: false - ); + $instruction = new CameraSetInstruction($preset_id, $ease, $camera_pos, $rot, $facing_pos, null, null, null, false); return new self([[$instruction, null, null, null]]); } diff --git a/src/muqsit/libcamera/libcamera.php b/src/muqsit/libcamera/libcamera.php index c28c634..c3a0495 100644 --- a/src/muqsit/libcamera/libcamera.php +++ b/src/muqsit/libcamera/libcamera.php @@ -32,127 +32,13 @@ public static function isRegistered(): bool{ public static function register(Plugin $plugin) : void{ !self::$registered || throw new BadMethodCallException("Tried to registered an already existing libcamera instance"); $preset_registry = new CameraPresetRegistry([ - "free" => new CameraPreset( - name: "minecraft:free", - parent: "", - xPosition: null, - yPosition: null, - zPosition: null, - pitch: null, - yaw: null, - rotationSpeed: null, - snapToTarget: null, - horizontalRotationLimit: null, - verticalRotationLimit: null, - continueTargeting: null, - blockListeningRadius: null, - viewOffset: null, - entityOffset: null, - radius: null, - yawLimitMin: null, - yawLimitMax: null, - audioListenerType: CameraPreset::AUDIO_LISTENER_TYPE_CAMERA, - playerEffects: false, - aimAssist: null, - controlScheme: null - ), - "first_person" => new CameraPreset( - name: "minecraft:first_person", - parent: "", - xPosition: null, - yPosition: null, - zPosition: null, - pitch: null, - yaw: null, - rotationSpeed: null, - snapToTarget: null, - horizontalRotationLimit: null, - verticalRotationLimit: null, - continueTargeting: null, - blockListeningRadius: null, - viewOffset: null, - entityOffset: null, - radius: null, - yawLimitMin: null, - yawLimitMax: null, - audioListenerType: CameraPreset::AUDIO_LISTENER_TYPE_PLAYER, - playerEffects: false, - aimAssist: null, - controlScheme: null - ), - "third_person" => new CameraPreset( - name: "minecraft:third_person", - parent: "", - xPosition: null, - yPosition: null, - zPosition: null, - pitch: null, - yaw: null, - rotationSpeed: null, - snapToTarget: null, - horizontalRotationLimit: null, - verticalRotationLimit: null, - continueTargeting: null, - blockListeningRadius: null, - viewOffset: null, - entityOffset: null, - radius: null, - yawLimitMin: null, - yawLimitMax: null, - audioListenerType: CameraPreset::AUDIO_LISTENER_TYPE_PLAYER, - playerEffects: false, - aimAssist: null, - controlScheme: null - ), - "third_person_front" => new CameraPreset( - name: "minecraft:third_person_front", - parent: "", - xPosition: null, - yPosition: null, - zPosition: null, - pitch: null, - yaw: null, - rotationSpeed: null, - snapToTarget: null, - horizontalRotationLimit: null, - verticalRotationLimit: null, - continueTargeting: null, - blockListeningRadius: null, - viewOffset: null, - entityOffset: null, - radius: null, - yawLimitMin: null, - yawLimitMax: null, - audioListenerType: CameraPreset::AUDIO_LISTENER_TYPE_PLAYER, - playerEffects: false, - aimAssist: null, - controlScheme: null - ), - "target" => new CameraPreset( - name: "minecraft:target", - parent: "minecraft:free", - xPosition: null, - yPosition: null, - zPosition: null, - pitch: null, - yaw: null, - rotationSpeed: 0.0, - snapToTarget: true, - horizontalRotationLimit: new Vector2(0.0, 360.0), - verticalRotationLimit: new Vector2(0.0, 180.0), - continueTargeting: true, - blockListeningRadius: 50.0, - viewOffset: null, - entityOffset: null, - radius: null, - yawLimitMin: null, - yawLimitMax: null, - audioListenerType: CameraPreset::AUDIO_LISTENER_TYPE_CAMERA, - playerEffects: false, - aimAssist: null, - controlScheme: null - ) + "free" => new CameraPreset("minecraft:free", "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_CAMERA, false, null, null), + "first_person" => new CameraPreset("minecraft:first_person", "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_PLAYER, false, null, null), + "third_person" => new CameraPreset("minecraft:third_person", "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_PLAYER, false, null, null), + "third_person_front" => new CameraPreset("minecraft:third_person_front", "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_PLAYER, false, null, null), + "target" => new CameraPreset("minecraft:target", "minecraft:free", null, null, null, null, null, 0.0, true, new Vector2(0.0, 360.0), new Vector2(0.0, 180.0), true, 50.0, null, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_CAMERA, false, null, null) ]); + $packet = CameraPresetsPacket::create(array_values($preset_registry->registered)); Server::getInstance()->getPluginManager()->registerEvent(DataPacketReceiveEvent::class, function(DataPacketReceiveEvent $event) use($packet) : void{ if($event->getPacket() instanceof SetLocalPlayerAsInitializedPacket){ From 28e04edf7057f7f7119cfef1222d87ab4e0f6399 Mon Sep 17 00:00:00 2001 From: DaisukeDaisuke <17798680+DaisukeDaisuke@users.noreply.github.com> Date: Wed, 6 Aug 2025 09:06:56 +0900 Subject: [PATCH 6/9] ai too bad --- README.md | 2 +- src/muqsit/libcamera/libcamera.php | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ce70fea..685f06d 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ if($player instanceof Player && $player->isOnline()){ CameraSetInstructionEaseType::IN_OUT_CUBIC, (float) 5.0 // duration (sec) ), - camera_pos: null, //Without it, the camera will teleport into subspace + camera_pos: null, rot: new CameraSetInstructionRotation( (float)20.0, //pitch (float)180.0 //yaw diff --git a/src/muqsit/libcamera/libcamera.php b/src/muqsit/libcamera/libcamera.php index c3a0495..d6821bf 100644 --- a/src/muqsit/libcamera/libcamera.php +++ b/src/muqsit/libcamera/libcamera.php @@ -25,22 +25,21 @@ final class libcamera{ private static bool $registered = false; private static CameraPresetRegistry $preset_registry; - public static function isRegistered(): bool{ + public static function isRegistered() : bool{ return self::$registered; } public static function register(Plugin $plugin) : void{ !self::$registered || throw new BadMethodCallException("Tried to registered an already existing libcamera instance"); $preset_registry = new CameraPresetRegistry([ - "free" => new CameraPreset("minecraft:free", "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_CAMERA, false, null, null), - "first_person" => new CameraPreset("minecraft:first_person", "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_PLAYER, false, null, null), - "third_person" => new CameraPreset("minecraft:third_person", "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_PLAYER, false, null, null), - "third_person_front" => new CameraPreset("minecraft:third_person_front", "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_PLAYER, false, null, null), - "target" => new CameraPreset("minecraft:target", "minecraft:free", null, null, null, null, null, 0.0, true, new Vector2(0.0, 360.0), new Vector2(0.0, 180.0), true, 50.0, null, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_CAMERA, false, null, null) + "free" => new CameraPreset("minecraft:free", "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_CAMERA, false, null, null), + "first_person" => new CameraPreset("minecraft:first_person", "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_PLAYER, false, null, null), + "third_person" => new CameraPreset("minecraft:third_person", "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_PLAYER, false, null, null), + "third_person_front" => new CameraPreset("minecraft:third_person_front", "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_PLAYER, false, null, null), + "target" => new CameraPreset("minecraft:target", "minecraft:free", null, null, null, null, null, 0.0, true, new Vector2(0.0, 360.0), new Vector2(0.0, 180.0), true, 50.0, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_CAMERA, false, null, null) ]); - $packet = CameraPresetsPacket::create(array_values($preset_registry->registered)); - Server::getInstance()->getPluginManager()->registerEvent(DataPacketReceiveEvent::class, function(DataPacketReceiveEvent $event) use($packet) : void{ + Server::getInstance()->getPluginManager()->registerEvent(DataPacketReceiveEvent::class, function(DataPacketReceiveEvent $event) use ($packet) : void{ if($event->getPacket() instanceof SetLocalPlayerAsInitializedPacket){ $event->getOrigin()->sendDataPacket($packet); } @@ -63,7 +62,7 @@ public static function getPresetRegistry() : CameraPresetRegistry{ } public static function parseEaseType(string $type) : int{ - return match($type){ + return match ($type) { "linear" => CameraSetInstructionEaseType::LINEAR, "spring" => CameraSetInstructionEaseType::SPRING, "in_quad" => CameraSetInstructionEaseType::IN_QUAD, From 5b2a79b7b2b6ce6131f4d733fa878e2492353b83 Mon Sep 17 00:00:00 2001 From: DaisukeDaisuke <17798680+DaisukeDaisuke@users.noreply.github.com> Date: Wed, 6 Aug 2025 09:13:13 +0900 Subject: [PATCH 7/9] Fix code style --- src/muqsit/libcamera/libcamera.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/muqsit/libcamera/libcamera.php b/src/muqsit/libcamera/libcamera.php index d6821bf..03360e4 100644 --- a/src/muqsit/libcamera/libcamera.php +++ b/src/muqsit/libcamera/libcamera.php @@ -44,7 +44,7 @@ public static function register(Plugin $plugin) : void{ $event->getOrigin()->sendDataPacket($packet); } }, EventPriority::MONITOR, $plugin); - Server::getInstance()->getPluginManager()->registerEvent(DataPacketSendEvent::class, function(DataPacketSendEvent $event) use ($packet) : void{ + Server::getInstance()->getPluginManager()->registerEvent(DataPacketSendEvent::class, function(DataPacketSendEvent $event) use($packet) : void{ foreach($event->getPackets() as $packet){ if($packet instanceof StartGamePacket){ $experiments = $packet->levelSettings->experiments->getExperiments(); @@ -62,7 +62,7 @@ public static function getPresetRegistry() : CameraPresetRegistry{ } public static function parseEaseType(string $type) : int{ - return match ($type) { + return match($type){ "linear" => CameraSetInstructionEaseType::LINEAR, "spring" => CameraSetInstructionEaseType::SPRING, "in_quad" => CameraSetInstructionEaseType::IN_QUAD, From 509d6b909c3ea27a334f325f793b74fe2d5c59bc Mon Sep 17 00:00:00 2001 From: DaisukeDaisuke <17798680+DaisukeDaisuke@users.noreply.github.com> Date: Wed, 6 Aug 2025 09:14:06 +0900 Subject: [PATCH 8/9] Fix code style --- src/muqsit/libcamera/libcamera.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/muqsit/libcamera/libcamera.php b/src/muqsit/libcamera/libcamera.php index 03360e4..6f9302d 100644 --- a/src/muqsit/libcamera/libcamera.php +++ b/src/muqsit/libcamera/libcamera.php @@ -39,12 +39,12 @@ public static function register(Plugin $plugin) : void{ "target" => new CameraPreset("minecraft:target", "minecraft:free", null, null, null, null, null, 0.0, true, new Vector2(0.0, 360.0), new Vector2(0.0, 180.0), true, 50.0, null, null, null, null, null, CameraPreset::AUDIO_LISTENER_TYPE_CAMERA, false, null, null) ]); $packet = CameraPresetsPacket::create(array_values($preset_registry->registered)); - Server::getInstance()->getPluginManager()->registerEvent(DataPacketReceiveEvent::class, function(DataPacketReceiveEvent $event) use ($packet) : void{ + Server::getInstance()->getPluginManager()->registerEvent(DataPacketReceiveEvent::class, function(DataPacketReceiveEvent $event) use($packet) : void{ if($event->getPacket() instanceof SetLocalPlayerAsInitializedPacket){ $event->getOrigin()->sendDataPacket($packet); } }, EventPriority::MONITOR, $plugin); - Server::getInstance()->getPluginManager()->registerEvent(DataPacketSendEvent::class, function(DataPacketSendEvent $event) use($packet) : void{ + Server::getInstance()->getPluginManager()->registerEvent(DataPacketSendEvent::class, function(DataPacketSendEvent $event) use ($packet) : void{ foreach($event->getPackets() as $packet){ if($packet instanceof StartGamePacket){ $experiments = $packet->levelSettings->experiments->getExperiments(); From bbf364b996bddc91720709637acc00e0d20421af Mon Sep 17 00:00:00 2001 From: DaisukeDaisuke <17798680+DaisukeDaisuke@users.noreply.github.com> Date: Wed, 6 Aug 2025 09:14:40 +0900 Subject: [PATCH 9/9] Fix code style --- src/muqsit/libcamera/libcamera.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/muqsit/libcamera/libcamera.php b/src/muqsit/libcamera/libcamera.php index 6f9302d..8db4326 100644 --- a/src/muqsit/libcamera/libcamera.php +++ b/src/muqsit/libcamera/libcamera.php @@ -25,7 +25,7 @@ final class libcamera{ private static bool $registered = false; private static CameraPresetRegistry $preset_registry; - public static function isRegistered() : bool{ + public static function isRegistered(): bool{ return self::$registered; }