Interface ModelScaler

All Known Implementing Classes:
ModelScaler.Composite

public sealed interface ModelScaler permits ModelScaler.Composite (not exhaustive)
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 Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Builder interface for creating Getters from JSON.
    static interface 
    Helper interface for built-in deserializers.
    static final class 
    Implementation of a composite scaler.
    static final class 
    Registry and factory for scalers.
    static interface 
    Functional interface for calculating scale.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The global deserializer instance for scalers.
  • Method Summary

    Modifier and Type
    Method
    Description
    default @NotNull ModelScaler
    composite(@NotNull ModelScaler scaler)
    Multiplies this scaler by another scaler.
    static @NotNull ModelScaler
    composite(@NotNull ModelScaler... scalers)
    Creates a composite scaler that multiplies the results of multiple scalers.
    @Nullable com.google.gson.JsonElement
    Returns the configuration data for this scaler as a JSON element.
    static @NotNull ModelScaler
    Returns the default scaler (constant 1.0).
    static @NotNull ModelScaler
    deserialize(@NotNull com.google.gson.JsonObject element)
    Deserializes a scaler from a JSON object.
    static @NotNull ModelScaler
    Returns a scaler that uses the entity's scale attribute.
    default @NotNull ModelScaler
    multiply(float value)
    Multiplies this scaler by a constant value.
    @NotNull String
    Returns the name of this scaler type.
    float
    scale(@NotNull Tracker tracker)
    Calculates the scale for a given tracker.
    default @NotNull com.google.gson.JsonObject
    Serializes this scaler to a JSON object.
    static @NotNull ModelScaler
    value(float value)
    Returns a constant value scaler.
  • Field Details

    • DESERIALIZER

      static final ModelScaler.Deserializer DESERIALIZER
      The global deserializer instance for scalers.
      Since:
      1.15.2
  • Method Details

    • name

      @NotNull @NotNull String name()
      Returns the name of this scaler type.
      Returns:
      the name
      Since:
      1.15.2
    • scale

      float scale(@NotNull @NotNull Tracker tracker)
      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

      @NotNull static @NotNull ModelScaler defaultScaler()
      Returns the default scaler (constant 1.0).
      Returns:
      the default scaler
      Since:
      1.15.2
    • entity

      @NotNull static @NotNull ModelScaler entity()
      Returns a scaler that uses the entity's scale attribute.
      Returns:
      the entity scaler
      Since:
      1.15.2
    • value

      @NotNull static @NotNull ModelScaler value(float value)
      Returns a constant value scaler.
      Parameters:
      value - the scale value
      Returns:
      the value scaler
      Since:
      1.15.2
    • composite

      @NotNull static @NotNull ModelScaler composite(@NotNull @NotNull ModelScaler... scalers)
      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

      @NotNull default @NotNull ModelScaler multiply(float value)
      Multiplies this scaler by a constant value.
      Parameters:
      value - the multiplier
      Returns:
      the new composite scaler
      Since:
      1.15.2
    • composite

      @NotNull default @NotNull ModelScaler composite(@NotNull @NotNull ModelScaler scaler)
      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