Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement API for new camera features #5832

Draft
wants to merge 7 commits into
base: minor-next
Choose a base branch
from

Conversation

IvanCraft623
Copy link
Member

Introduction

Implement an appropriate API for this to make it easier for developers to use these new features and create fabulous cinematics.

Changes

API changes

  • The following new classes have been added:
    • pocketmine\data\bedrock\CameraEaseTypeIdMap
    • pocketmine\player\camera\CameraEaseType
    • pocketmine\player\camera\CameraPreset
    • pocketmine\player\camera\CameraPresetFactory
    • pocketmine\player\camera\VanillaCameraPresets
    • pocketmine\player\camera\element\CameraEase
    • pocketmine\player\camera\element\CameraState
    • pocketmine\player\camera\instruction\ClearCameraInstruction
    • pocketmine\player\camera\instruction\FadeCameraInstruction
    • pocketmine\player\camera\instruction\SetCameraInstruction
  • The following API methods have been added:
    • public Player->sendCameraInstruction(CameraInstruction ...$instructions) : void

Behavioural changes

  • Server now sends CameraPresetsPacket during PreSpawn
  • Experiments now are send as true in LevelSettings & ResourcePackStackPacket

Follow-up

  • Swap the tag name of the Blue and Green colors when enconding them (if mojang fixes it)

Tests

  • NBT tree data were obtained using ProxyPass + BDS.
  • I created a small plugin for camera testing. CameraTest.zip
    The following tests can be found int the plugin:
    • /camera cinematic - a basic cinematic that follows the player
    • /camera multiple - a test that sends two instuctions in a single packet
    • /camera clear - returns the player's camera back to normal
    • /camera fade [r] [g] [b] [fadeInSeconds] [holdSeconds] [fadeOutSeconds] - allows fade the camera
    • /camera set <preset> [x] [y] [z] [yaw] [pitch] [easeType] [easeDuration] - allows test presets

Missing camera set
- Fix fade color not being played correctyl (blame microsoft)
- Fix rotation not being encoded correctly
@@ -2095,6 +2096,10 @@ public function sendToastNotification(string $title, string $body) : void{
$this->getNetworkSession()->onToastNotification($title, $body);
}

public function sendCameraInstruction(CameraInstruction ...$instructions) : void{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sendCameraInstructions() would more fit according to the parameter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put it this way because most of the time only a single instruction is sent

@@ -1152,6 +1169,15 @@ public function onToastNotification(string $title, string $body) : void{
$this->sendDataPacket(ToastRequestPacket::create($title, $body));
}

public function onCameraInstruction(CameraInstruction ...$instructions) : void{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sendCameraInstructions() would more fit according to the parameter.

interface CameraInstruction{

/**
* Writes this instriction in a CompoundTag in order to be sent to the client.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Writes this instriction in a CompoundTag in order to be sent to the client.
* Writes this instruction in a CompoundTag in order to be sent to the client.


public function __construct(
private CameraEaseType $type,
private float $duration //in seconds
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should put the comment in phpdoc? Maybe at the getDuration function too?

@dktapps
Copy link
Member

dktapps commented Jun 19, 2023

I don't this should be merged unless these features become non-experimental. Until they stabilize, we can't introduce API for them.

@dktapps dktapps added Category: API Related to the plugin API Category: Gameplay Related to Minecraft gameplay experience Status: Blocked Depends on other changes which are yet to be completed labels Jun 19, 2023
@Wertzui123
Copy link
Contributor

I don't this should be merged unless these features become non-experimental.

They're now non-experimental since 1.20.30.

@IvanCraft623
Copy link
Member Author

This PR isn't updated to the latest changes in 1.20.30, I will convert it to a draft until this is fixed.

@IvanCraft623 IvanCraft623 marked this pull request as draft September 27, 2023 01:01
@Refaltor77
Copy link

To help you, I corrected the packet, now has work : pmmp/BedrockProtocol#198

@inxomnyaa
Copy link
Contributor

What's blocking the progress on this? Anything i can do to advance it?

@IvanCraft623
Copy link
Member Author

What's blocking the progress on this? Anything i can do to advance it?

The PR is stale and the camera system it's still on "early" development, it gets changes almost every new protocol version.

@dktapps dktapps added Status: Waiting on Author Type: Enhancement Contributes features or other improvements to PocketMine-MP and removed Status: Blocked Depends on other changes which are yet to be completed labels Nov 23, 2024
Copy link

github-actions bot commented Dec 7, 2024

This PR has been marked as "Waiting on Author", but we haven't seen any activity in 7 days.

If there is no further activity, it will be closed in 28 days.

Note for maintainers: Adding an assignee to the PR will prevent it from being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: API Related to the plugin API Category: Gameplay Related to Minecraft gameplay experience Stale Status: Waiting on Author Type: Enhancement Contributes features or other improvements to PocketMine-MP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants