Record Class InstancerProviderImpl

java.lang.Object
java.lang.Record
dev.engine_room.flywheel.backend.engine.InstancerProviderImpl
All Implemented Interfaces:
InstancerProvider

public record InstancerProviderImpl(EngineImpl engine) extends Record implements InstancerProvider
  • Constructor Details

    • InstancerProviderImpl

      public InstancerProviderImpl(EngineImpl engine)
      Creates an instance of a InstancerProviderImpl record class.
      Parameters:
      engine - the value for the engine record component
  • Method Details

    • instancer

      public <I extends Instance> Instancer<I> instancer(InstanceType<I> type, Model model, int bias)
      Description copied from interface: InstancerProvider
      Get an instancer for the given instance type rendering the given model.

      Calling this method twice with the same arguments in the same frame will return the same instancer.

      It is NOT safe to store instancers between frames. Each time you need an instancer, you should call this method.

      Render Order

      In general, you can assume all instances in the same instancer will be rendered in a single draw call. Backends are free to optimize the ordering of draw calls to a certain extent, but utilities are provided to let you exert control over the ordering.

      Mesh Order

      For one, Meshes within a Model are guaranteed to render in the order they appear in their containing list. This lets you e.g. preserve (or break!) vanilla's chunk RenderType order guarantees or control which Meshes of your Model render over others.

      Bias Order

      The other method is via the bias parameter to this method. An instancer with a lower bias will have its instances draw BEFORE an instancer with a higher bias. This allows you to control the render order between your instances to e.g. create an "overlay" instance to selectively color or apply decals to another instance.

      Specified by:
      instancer in interface InstancerProvider
      Parameters:
      type - The instance type to parameterize your instances by.
      model - The Model to instance.
      bias - A weight to control render order between instancers. Instancers are rendered in ascending order by bias.
      Returns:
      An instancer.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • engine

      public EngineImpl engine()
      Returns the value of the engine record component.
      Returns:
      the value of the engine record component