Class ModelDataManager

java.lang.Object
net.neoforged.neoforge.client.model.data.ModelDataManager

public class ModelDataManager extends Object
A manager for the lifecycle of all the ModelData instances in a Level. Users should not instantiate this unless they know what they are doing. The manager is also not thread-safe, it should only be interacted with on the main client thread.
  • Field Details

    • owningThread

      private final Thread owningThread
    • level

      private final Level level
    • needModelDataRefresh

      private final it.unimi.dsi.fastutil.longs.Long2ObjectMap<Set<BlockPos>> needModelDataRefresh
    • modelDataCache

      private final it.unimi.dsi.fastutil.longs.Long2ObjectMap<it.unimi.dsi.fastutil.longs.Long2ObjectMap<ModelData>> modelDataCache
    • EMPTY_SNAPSHOT

      public static final it.unimi.dsi.fastutil.longs.Long2ObjectFunction<ModelData> EMPTY_SNAPSHOT
  • Constructor Details

    • ModelDataManager

      public ModelDataManager(Level level)
  • Method Details

    • requestRefresh

      public void requestRefresh(BlockEntity blockEntity)
      Request a refresh of the stored data for the given BlockEntity. The given BlockEntity must be in the level owning this manager
    • getAt

      public @UnmodifiableView it.unimi.dsi.fastutil.longs.Long2ObjectMap<ModelData> getAt(SectionPos pos)
      Provides all the model data for a given chunk section. This is useful for mods which wish to retrieve a fast view of the model data for a single section in a level.

      The returned map must be copied if it needs to be accessed from another thread, as it may be modified by this data manager.

      Parameters:
      pos - the section to query
      Returns:
      an (unmodifiable) map containing the ModelData stored for the given chunk section
    • getAt

      public ModelData getAt(BlockPos pos)
      Retrieves model data for a block at the given position.
      Parameters:
      pos - the position to query
      Returns:
      the model data at this position, or ModelData.EMPTY if none exists
    • snapshotSectionRegion

      public it.unimi.dsi.fastutil.longs.Long2ObjectFunction<ModelData> snapshotSectionRegion(int sectionMinX, int sectionMinY, int sectionMinZ, int sectionMaxX, int sectionMaxY, int sectionMaxZ)
      Snapshot the state of this manager for all sections in the volume specified by the given section coordinates. The snapshot will return ModelData.EMPTY for nonexistent keys.
    • refreshAt

      private void refreshAt(long section)
    • isOtherThread

      private boolean isOtherThread()
    • onChunkUnload

      public static void onChunkUnload(ChunkEvent.Unload event)