Class AbstractInstance

java.lang.Object
com.jozufozu.flywheel.backend.instancing.AbstractInstance
All Implemented Interfaces:
Instance, LightListener
Direct Known Subclasses:
BlockEntityInstance, EntityInstance

public abstract class AbstractInstance extends Object implements Instance, LightListener
A general interface providing information about any type of thing that could use Flywheel's instanced rendering. Right now, that's only BlockEntityInstanceManager, but there could be an entity equivalent in the future.
  • Field Details

    • materialManager

      protected final MaterialManager materialManager
    • world

      public final net.minecraft.world.level.Level world
    • removed

      protected boolean removed
  • Constructor Details

    • AbstractInstance

      public AbstractInstance(MaterialManager materialManager, net.minecraft.world.level.Level world)
  • Method Details

    • init

      public void init()
      Initialize models here.
    • removeAndMark

      public final void removeAndMark()
    • remove

      protected abstract void remove()
      Free any acquired resources.
    • update

      public void update()
      Update instance data here. Good for when data doesn't change very often and when animations are GPU based. Don't query lighting data here, that's handled separately in updateLight().

      If your animations are complex or more CPU driven, see DynamicInstance or TickableInstance.
    • updateLight

      public void updateLight()
      Called after construction and when a light update occurs in the world.
      If your model needs it, update light here.
    • shouldReset

      public boolean shouldReset()
      When an instance is reset, the instance is deleted and re-created.

      Just before update() would be called, shouldReset() is checked. If this function returns true, then this instance will be removed, and another instance will be constructed to replace it. This allows for more sane resource acquisition compared to trying to update everything within the lifetime of an instance.

      Returns:
      true if this instance should be discarded and refreshed.
    • isListenerInvalid

      public boolean isListenerInvalid()
      Description copied from interface: LightListener
      Check the status of the light listener.
      Specified by:
      isListenerInvalid in interface LightListener
      Returns:
      true if the listener is invalid/removed/deleted, and should no longer receive updates.
    • onLightUpdate

      public void onLightUpdate(net.minecraft.world.level.LightLayer type, ImmutableBox changed)
      Description copied from interface: LightListener
      Called when a light updates in a chunk the implementor cares about.
      Specified by:
      onLightUpdate in interface LightListener
    • relight

      protected void relight(net.minecraft.core.BlockPos pos, FlatLit<?>... models)
    • relight

      protected <L extends FlatLit<?>> void relight(net.minecraft.core.BlockPos pos, Stream<L> models)
    • relight

      protected void relight(int block, int sky, FlatLit<?>... models)
    • relight

      protected <L extends FlatLit<?>> void relight(int block, int sky, Stream<L> models)