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

Feature: Camera/Input locking API #4332

Merged
merged 35 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ac5b90a
Start on camera api
onebeastchris Aug 13, 2023
59f103c
Merge remote-tracking branch 'upstream/master' into camera-api
onebeastchris Nov 15, 2023
e775a0d
init impl
onebeastchris Nov 15, 2023
5af4511
Seperate CameraMovement and CameraFade
onebeastchris Dec 5, 2023
1e71976
Expose Player Position, input/camera lock api
onebeastchris Dec 5, 2023
f6a02de
int -> float for durations
onebeastchris Dec 5, 2023
7d1a583
Merge remote-tracking branch 'upstream/master' into camera-api
onebeastchris Dec 8, 2023
25e6ff3
Created CameraUtil (may need to be converted to a registry thingy) to…
onebeastchris Dec 8, 2023
9eb281a
oops
onebeastchris Dec 8, 2023
0fb76fb
Undo import changes
onebeastchris Dec 8, 2023
d23b4df
Formatting
onebeastchris Dec 8, 2023
14996e6
Fix nullability issues
onebeastchris Dec 10, 2023
f0fa2f3
Expose GeyserPlayerEntity (self) in GeyserConnection
onebeastchris Dec 11, 2023
e580f06
Expose GeyserPlayerEntity (self) in GeyserConnection
onebeastchris Dec 11, 2023
2c9c5db
Adjust Javadocs
onebeastchris Dec 11, 2023
ba67566
more javadocs
onebeastchris Dec 11, 2023
7d27faf
- NonNull Color instead of r/g/b values in the fade
onebeastchris Dec 11, 2023
d018766
Merge remote-tracking branch 'upstream/master' into camera-api
onebeastchris Dec 19, 2023
279daa9
address review by @konicai
onebeastchris Dec 19, 2023
e77c904
Changes:
onebeastchris Dec 20, 2023
2690ec3
start: EntityExpansion
onebeastchris Dec 20, 2023
fafd8a3
EntityExpansion
onebeastchris Dec 20, 2023
cf0831a
only import color, remove some empty space, add missing nonnull annot…
onebeastchris Dec 20, 2023
94feeb7
fix various issues
onebeastchris Dec 20, 2023
8adbc3d
Rename EntityExpansion.java and CameraExpansion.java to EntityData an…
onebeastchris Jan 6, 2024
0927191
Merge remote-tracking branch 'upstream/master' into camera-api
onebeastchris Jan 26, 2024
1003fd6
Clean up Javadocs, more enforcing of NonNull arguments
onebeastchris Jan 26, 2024
936b74f
final cleanup, bump to 2.2.2 snapshot
onebeastchris Jan 26, 2024
5d40309
oops
onebeastchris Jan 26, 2024
a6f5861
dont end return statements in javadocs with period
onebeastchris Jan 27, 2024
4eb6f57
cleaner checking for null args on nonnull annotated method params
onebeastchris Jan 29, 2024
5babcce
more consistency in naming
onebeastchris Jan 29, 2024
0ce05d9
Remove experiments, fix camera fades not being sent in position instr…
onebeastchris Jan 31, 2024
1105466
update docs, total fade can be up to 30 seconds
onebeastchris Jan 31, 2024
78a5432
i can't count, it should be 2.2.2; not 2.2.3
onebeastchris Jan 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/

package org.geysermc.geyser.api.bedrock.camera;

public enum CameraEaseType {
LINEAR("linear"),
SPRING("spring"),
EASE_IN_SINE("in_sine"),
EASE_OUT_SINE("out_sine"),
EASE_IN_OUT_SINE("in_out_sine"),
EASE_IN_QUAD("in_quad"),
EASE_OUT_QUAD("out_quad"),
EASE_IN_OUT_QUAD("in_out_quad"),
EASE_IN_CUBIC("in_cubic"),
EASE_OUT_CUBIC("out_cubic"),
EASE_IN_OUT_CUBIC("in_out_cubic"),
EASE_IN_QUART("in_quart"),
EASE_OUT_QUART("out_quart"),
EASE_IN_OUT_QUART("in_out_quart"),
EASE_IN_QUINT("in_quint"),
EASE_OUT_QUINT("out_quint"),
EASE_IN_OUT_QUINT("in_out_quint"),
EASE_IN_EXPO("in_expo"),
EASE_OUT_EXPO("out_expo"),
EASE_IN_OUT_EXPO("in_out_expo"),
EASE_IN_CIRC("in_circ"),
EASE_OUT_CIRC("out_circ"),
EASE_IN_OUT_CIRC("in_out_circ"),
EASE_IN_BACK("in_back"),
EASE_OUT_BACK("out_back"),
EASE_IN_OUT_BACK("in_out_back"),
EASE_IN_ELASTIC("in_elastic"),
EASE_OUT_ELASTIC("out_elastic"),
EASE_IN_OUT_ELASTIC("in_out_elastic"),
EASE_IN_BOUNCE("in_bounce"),
EASE_OUT_BOUNCE("out_bounce"),
EASE_IN_OUT_BOUNCE("in_out_bounce");

private final String id;

CameraEaseType(String id) {
this.id = id;
}

public String id() {
return this.id;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/

package org.geysermc.geyser.api.bedrock.camera;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.common.value.qual.IntRange;
import org.geysermc.geyser.api.GeyserApi;

import java.awt.*;

/**
* Represents a coloured fade overlay on the camera.
*/
public interface CameraFade {

/**
* Gets the color overlay of the camera.
* Bedrock uses an RGB color system.
*
* @return the color of the fade
*/
@NonNull Color color();

/**
* Gets the seconds it takes to fade in.
* All fade times combined must take at least 0.5 seconds, and at most 10 seconds.
*
* @return the seconds it takes to fade in
*/
float fadeInSeconds();

/**
* Gets the seconds the overlay is held.
* All fade times combined must take at least 0.5 seconds, and at most 10 seconds.
*
* @return the seconds the overlay is held
*/
float holdSeconds();

/**
* Gets the seconds it takes to fade out.
* All fade times combined must take at least 0.5 seconds, and at most 10 seconds.
*
* @return the seconds it takes to fade out
*/
float fadeOutSeconds();

/**
* Creates a Builder for CameraFade
*
* @return a CameraFade Builder
*/
static CameraFade.Builder builder() {
return GeyserApi.api().provider(CameraFade.Builder.class);
}

interface Builder {

Builder color(@NonNull Color color);

Builder fadeInSeconds(@IntRange(from = 0, to = 10)float fadeInSeconds);

Builder holdSeconds(@IntRange(from = 0, to = 10)float holdSeconds);

Builder fadeOutSeconds(@IntRange(from = 0, to = 10) float fadeOutSeconds);

CameraFade build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/

package org.geysermc.geyser.api.bedrock.camera;

/**
* Represents a camera perspective that a player's camera can take.
* All perspectives except for {@link #FREE} are locked to the player's head, and are therefore relative to the player's rotation.
*/
public enum CameraPerspective {
FIRST_PERSON("minecraft:first_person"),
FREE("minecraft:free"),
THIRD_PERSON("minecraft:third_person"),
THIRD_PERSON_FRONT("minecraft:third_person_front");

private final String id;

CameraPerspective(String id) {
this.id = id;
}

public String id() {
return this.id;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/

package org.geysermc.geyser.api.bedrock.camera;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.common.value.qual.IntRange;
import org.geysermc.geyser.api.GeyserApi;
import org.geysermc.geyser.api.util.Position;

public interface CameraPosition {

/**
* Gets the camera's {@link Position}.
*
* @return camera position
*/
@NonNull Position position();

/**
* Gets the {@link CameraEaseType} of the camera.
* If not set, there is no easing.
*
* @return camera ease type
*/
@Nullable CameraEaseType easeType();

/**
* Gets the easing duration of the camera.
* Is only used if a {@link CameraEaseType} is set.
*
* @return camera easing duration
*/
float easeDuration();

/**
* Gets the x-axis rotation of the camera.
* To prevent the camera from being upside down, Bedrock limits the range to -90 to 90.
* Will be overridden if {@link #facingPosition()} is set.
*
* @return camera x-axis rotation
*/
@IntRange(from = -90, to = 90) int rotationX();

/**
* Gets the y-axis rotation of the camera.
* Will be overridden if {@link #facingPosition()} is set.
*
* @return camera y-axis rotation
*/
int rotationY();

/**
* Gets the position that the camera is facing.
* Can be used instead of manually setting rotation values.
* <p>
* If set, the rotation values set via {@link #rotationX()} and {@link #rotationY()} will be ignored.
*
* @return Camera's facing position
*/
@Nullable Position facingPosition();

/**
* Controls whether player effects, such as night vision or blindness, should be rendered on the camera.
* Defaults to false.
*
* @return whether player effects should be rendered
*/
boolean renderPlayerEffects();

/**
* Controls whether the player position should be used for directional audio.
* If false, the camera position will be used instead.
*
* @return whether the players position should be used for directional audio
*/
boolean playerPositionForAudio();

/**
* Creates a Builder for CameraPosition
*
* @return a CameraPosition Builder
*/
static CameraPosition.Builder builder() {
return GeyserApi.api().provider(CameraPosition.Builder.class);
}

interface Builder {

Builder fade(@Nullable CameraFade fade);

Builder renderPlayerEffects(boolean renderPlayerEffects);

Builder playerPositionForAudio(boolean playerPositionForAudio);

Builder easeType(@Nullable CameraEaseType easeType);

Builder easeDuration(float easeDuration);

Builder position(@NonNull Position position);

Builder rotationX(int rotX);

Builder rotationY(int rotY);

Builder facingPosition(@Nullable Position facingPosition);

CameraPosition build();
}
}
Loading