Class InstanceManager<T>

java.lang.Object
com.jozufozu.flywheel.backend.instancing.InstanceManager<T>
All Implemented Interfaces:
InstancingEngine.OriginShiftListener
Direct Known Subclasses:
BlockEntityInstanceManager, EntityInstanceManager

public abstract class InstanceManager<T> extends Object implements InstancingEngine.OriginShiftListener
  • Field Details

  • Constructor Details

    • InstanceManager

      public InstanceManager(MaterialManager materialManager)
  • Method Details

    • createUpdateLimiter

      protected DistanceUpdateLimiter createUpdateLimiter()
    • getObjectCount

      public int getObjectCount()
      Get the number of game objects that are currently being instanced.
      Returns:
      The object count.
    • canInstance

      protected abstract boolean canInstance(T obj)
      Is the given object capable of being instanced at all?
      Returns:
      false if on object cannot be instanced.
    • canCreateInstance

      protected abstract boolean canCreateInstance(T obj)
      Is the given object currently capable of being instanced?

      This won't be the case for TEs or entities that are outside of loaded chunks.

      Returns:
      true if the object is currently capable of being instanced.
    • createRaw

      @Nullable protected abstract AbstractInstance createRaw(T obj)
    • tick

      public void tick(TaskEngine taskEngine, double cameraX, double cameraY, double cameraZ)
      Ticks the InstanceManager.

      TickableInstances get ticked.
      Queued updates are processed.

    • tickInstance

      protected void tickInstance(int cX, int cY, int cZ, TickableInstance instance)
    • beginFrame

      public void beginFrame(TaskEngine taskEngine, net.minecraft.client.Camera info)
    • updateInstance

      protected void updateInstance(DynamicInstance dyn, float lookX, float lookY, float lookZ, int cX, int cY, int cZ)
    • add

      public void add(T obj)
    • queueAdd

      public void queueAdd(T obj)
    • queueUpdate

      public void queueUpdate(T obj)
    • update

      public void update(T obj)
      Update the instance associated with an object.

      By default this is the only hook an IInstance has to change its internal state. This is the lowest frequency update hook IInstance gets. For more frequent updates, see TickableInstance and DynamicInstance.

      Parameters:
      obj - the object to update.
    • remove

      public void remove(T obj)
    • invalidate

      public void invalidate()
    • getInstance

      @Nullable protected <I extends T> AbstractInstance getInstance(I obj)
    • processQueuedAdditions

      protected void processQueuedAdditions()
    • processQueuedUpdates

      protected void processQueuedUpdates()
    • addInternal

      protected void addInternal(T obj)
    • removeInternal

      protected void removeInternal(T obj, AbstractInstance instance)
    • createInternal

      @Nullable protected AbstractInstance createInternal(T obj)
    • onOriginShift

      public void onOriginShift()
      Specified by:
      onOriginShift in interface InstancingEngine.OriginShiftListener
    • detachLightListeners

      public void detachLightListeners()
    • queueAddAll

      public void queueAddAll(Collection<? extends T> objects)