Interface ModelScaler
- All Known Implementing Classes:
ModelScaler.Composite
Defines how a model's scale is calculated.
Scalers can be constant values, derived from entity attributes, or composites of multiple scalers. They are serializable to JSON for configuration purposes.
- 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 classImplementation of a composite scaler.static final classRegistry and factory for scalers.static interfaceFunctional interface for calculating scale. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ModelScaler.DeserializerThe global deserializer instance for scalers. -
Method Summary
Modifier and TypeMethodDescriptiondefault @NotNull ModelScalercomposite(@NotNull ModelScaler scaler) Multiplies this scaler by another scaler.static @NotNull ModelScalercomposite(@NotNull ModelScaler... scalers) Creates a composite scaler that multiplies the results of multiple scalers.@Nullable com.google.gson.JsonElementdata()Returns the configuration data for this scaler as a JSON element.static @NotNull ModelScalerReturns the default scaler (constant 1.0).static @NotNull ModelScalerdeserialize(@NotNull com.google.gson.JsonObject element) Deserializes a scaler from a JSON object.static @NotNull ModelScalerentity()Returns a scaler that uses the entity's scale attribute.default @NotNull ModelScalermultiply(float value) Multiplies this scaler by a constant value.@NotNull Stringname()Returns the name of this scaler type.floatCalculates the scale for a given tracker.default @NotNull com.google.gson.JsonObjectSerializes this scaler to a JSON object.static @NotNull ModelScalervalue(float value) Returns a constant value scaler.
-
Field Details
-
DESERIALIZER
The global deserializer instance for scalers.- Since:
- 1.15.2
-
-
Method Details
-
name
Returns the name of this scaler type.- Returns:
- the name
- Since:
- 1.15.2
-
scale
Calculates the scale for a given tracker.- Parameters:
tracker- the tracker- Returns:
- the calculated scale factor
- Since:
- 1.15.2
-
data
@Nullable @Nullable com.google.gson.JsonElement data()Returns the configuration data for this scaler as a JSON element.- Returns:
- the data, or null if none
- Since:
- 1.15.2
-
deserialize
@NotNull static @NotNull ModelScaler deserialize(@NotNull @NotNull com.google.gson.JsonObject element) Deserializes a scaler from a JSON object.- Parameters:
element- the JSON object- Returns:
- the deserialized scaler, or the default scaler if invalid
- Since:
- 1.15.2
-
defaultScaler
Returns the default scaler (constant 1.0).- Returns:
- the default scaler
- Since:
- 1.15.2
-
entity
Returns a scaler that uses the entity's scale attribute.- Returns:
- the entity scaler
- Since:
- 1.15.2
-
value
Returns a constant value scaler.- Parameters:
value- the scale value- Returns:
- the value scaler
- Since:
- 1.15.2
-
composite
Creates a composite scaler that multiplies the results of multiple scalers.- Parameters:
scalers- the scalers to combine- Returns:
- the composite scaler
- Since:
- 1.15.2
-
multiply
Multiplies this scaler by a constant value.- Parameters:
value- the multiplier- Returns:
- the new composite scaler
- Since:
- 1.15.2
-
composite
Multiplies this scaler by another scaler.- Parameters:
scaler- the other scaler- Returns:
- the new composite scaler
- Since:
- 1.15.2
-
serialize
@NotNull default @NotNull com.google.gson.JsonObject serialize()Serializes this scaler to a JSON object.- Returns:
- the JSON object
- Since:
- 1.15.2
-