Class LightStorage<M extends ChunkToNibbleArrayMap<M>>

Direct Known Subclasses:
BlockLightStorage, SkyLightStorage

public abstract class LightStorage<M extends ChunkToNibbleArrayMap<M>>
extends SectionDistanceLevelPropagator
LightStorage handles the access, storage and propagation of a specific kind of light within the world. For example, separate instances will be used to store block light as opposed to sky light.

The smallest unit within LightStorage is the section. Sections represent a cube of 16x16x16 blocks and their lighting data. In turn, 16 sections stacked on top of each other form a column, which are analogous to the standard 16x256x16 world chunks.

To avoid allocations, LightStorage packs all the coordinate arguments into single long values. Extra care should be taken to ensure that the relevant types are being used where appropriate.

See Also:
SkyLightStorage, BlockLightStorage
  • Field Details

    • EMPTY

      protected static final ChunkNibbleArray EMPTY
    • DIRECTIONS

      private static final Direction[] DIRECTIONS
    • lightType

      private final LightType lightType
    • chunkProvider

      private final ChunkProvider chunkProvider
    • readySections

      protected final LongSet readySections
    • markedNotReadySections

      protected final LongSet markedNotReadySections
    • markedReadySections

      protected final LongSet markedReadySections
    • uncachedStorage

      protected volatile M extends ChunkToNibbleArrayMap<M> uncachedStorage
    • storage

      protected final M extends ChunkToNibbleArrayMap<M> storage
    • dirtySections

      protected final LongSet dirtySections
    • notifySections

      protected final LongSet notifySections
    • queuedSections

      protected final Long2ObjectMap<ChunkNibbleArray> queuedSections
    • queuedEdgeSections

      private final LongSet queuedEdgeSections
    • columnsToRetain

      private final LongSet columnsToRetain
    • sectionsToRemove

      private final LongSet sectionsToRemove
    • hasLightUpdates

      protected volatile boolean hasLightUpdates
  • Constructor Details

  • Method Details

    • hasSection

      protected boolean hasSection​(long sectionPos)
    • getLightSection

      @Nullable protected ChunkNibbleArray getLightSection​(long sectionPos, boolean cached)
    • getLightSection

      @Nullable protected ChunkNibbleArray getLightSection​(M storage, long sectionPos)
    • getLightSection

      @Nullable public ChunkNibbleArray getLightSection​(long sectionPos)
    • getLight

      protected abstract int getLight​(long blockPos)
    • get

      protected int get​(long blockPos)
    • set

      protected void set​(long blockPos, int value)
    • getLevel

      protected int getLevel​(long id)
      Specified by:
      getLevel in class LevelPropagator
    • getInitialLevel

      protected int getInitialLevel​(long id)
      Specified by:
      getInitialLevel in class SectionDistanceLevelPropagator
    • setLevel

      protected void setLevel​(long id, int level)
      Specified by:
      setLevel in class LevelPropagator
    • createSection

      protected ChunkNibbleArray createSection​(long sectionPos)
    • removeSection

      protected void removeSection​(ChunkLightProvider<?,​?> storage, long sectionPos)
    • hasLightUpdates

      protected boolean hasLightUpdates()
    • updateLight

      protected void updateLight​(ChunkLightProvider<M,​?> lightProvider, boolean doSkylight, boolean skipEdgeLightPropagation)
    • updateSection

      private void updateSection​(ChunkLightProvider<M,​?> lightProvider, long sectionPos)
    • onLoadSection

      protected void onLoadSection​(long sectionPos)
    • onUnloadSection

      protected void onUnloadSection​(long sectionPos)
    • setColumnEnabled

      protected void setColumnEnabled​(long columnPos, boolean enabled)
    • setRetainColumn

      public void setRetainColumn​(long sectionPos, boolean retain)
    • enqueueSectionData

      protected void enqueueSectionData​(long sectionPos, @Nullable ChunkNibbleArray array, boolean bool)
    • setSectionStatus

      protected void setSectionStatus​(long sectionPos, boolean notReady)
    • updateAll

      protected void updateAll()
    • notifyChanges

      protected void notifyChanges()