Package kr.toxicity.model.api.tracker
Interface ModelRotator
- All Superinterfaces:
BiFunction<Tracker,ModelRotation, ModelRotation>
- All Known Implementing Classes:
ModelRotator.SourcedRotator
public sealed interface ModelRotator
extends BiFunction<Tracker,ModelRotation,ModelRotation>
permits ModelRotator.SourcedRotator (not exhaustive)
Defines how a model's rotation is calculated and applied.
Rotators can modify the base rotation (e.g., only applying yaw, smoothing rotation) and can be chained together.
- Since:
- 1.15.2
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceBuilder interface for creating Getters from JSON.static interfaceHelper interface for built-in deserializers.static final classRegistry and factory for rotators.static interfaceFunctional interface for calculating rotation.static final recordImplementation of a chained rotator. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final @NotNull ModelRotatorDefault rotator (applies rotation as-is).static final ModelRotator.DeserializerThe global deserializer instance for rotators.static final @NotNull ModelRotatorEmpty rotator (returns zero rotation).static final @NotNull ModelRotatorPitch-only rotator.static final @NotNull ModelRotatorYaw-only rotator. -
Method Summary
Modifier and TypeMethodDescriptiondefault @NotNull ModelRotationApplies the rotator to a tracker with default rotation.@NotNull ModelRotationapply(@NotNull Tracker tracker, @NotNull ModelRotation rotation) Applies the rotator to a tracker with a base rotation.@Nullable com.google.gson.JsonElementdata()Returns the configuration data for this rotator.static @NotNull ModelRotatordeserialize(@NotNull com.google.gson.JsonObject object) Deserializes a rotator from a JSON object.static @NotNull ModelRotatorlazy(long mills) Creates a lazy rotator that smooths rotation over time.@NotNull Stringname()Returns the name of this rotator type.default @NotNull ModelRotatorroot()Returns the root rotator in the chain.default @NotNull com.google.gson.JsonObjectSerializes this rotator to a JSON object.@Nullable ModelRotatorsource()Returns the source rotator if this is a chained rotator.default @NotNull ModelRotatorthen(@NotNull ModelRotator rotator) Chains this rotator with another one.Methods inherited from interface java.util.function.BiFunction
andThen
-
Field Details
-
DESERIALIZER
The global deserializer instance for rotators.- Since:
- 1.15.2
-
DEFAULT
Default rotator (applies rotation as-is).- Since:
- 1.15.2
-
EMPTY
Empty rotator (returns zero rotation).- Since:
- 1.15.2
-
PITCH
Pitch-only rotator.- Since:
- 1.15.2
-
YAW
Yaw-only rotator.- Since:
- 1.15.2
-
-
Method Details
-
deserialize
@NotNull static @NotNull ModelRotator deserialize(@NotNull @NotNull com.google.gson.JsonObject object) Deserializes a rotator from a JSON object.- Parameters:
object- the JSON object- Returns:
- the deserialized rotator, or EMPTY if invalid
- Since:
- 1.15.2
-
lazy
Creates a lazy rotator that smooths rotation over time.- Parameters:
mills- the smoothing duration in milliseconds- Returns:
- the lazy rotator
- Since:
- 1.15.2
-
name
Returns the name of this rotator type.- Returns:
- the name
- Since:
- 1.15.2
-
source
Returns the source rotator if this is a chained rotator.- Returns:
- the source rotator, or null
- Since:
- 1.15.2
-
data
@Nullable @Nullable com.google.gson.JsonElement data()Returns the configuration data for this rotator.- Returns:
- the data, or null
- Since:
- 1.15.2
-
root
Returns the root rotator in the chain.- Returns:
- the root rotator
- Since:
- 1.15.2
-
serialize
@NotNull default @NotNull com.google.gson.JsonObject serialize()Serializes this rotator to a JSON object.- Returns:
- the JSON object
- Since:
- 1.15.2
-
apply
Applies the rotator to a tracker with default rotation.- Parameters:
tracker- the tracker- Returns:
- the calculated rotation
- Since:
- 1.15.2
-
apply
@NotNull @NotNull ModelRotation apply(@NotNull @NotNull Tracker tracker, @NotNull @NotNull ModelRotation rotation) Applies the rotator to a tracker with a base rotation.- Specified by:
applyin interfaceBiFunction<Tracker,ModelRotation, ModelRotation> - Parameters:
tracker- the trackerrotation- the base rotation- Returns:
- the calculated rotation
- Since:
- 1.15.2
-
then
Chains this rotator with another one.- Parameters:
rotator- the next rotator in the chain- Returns:
- the chained rotator
- Since:
- 1.15.2
-