Class ModelDataManager

java.lang.Object
net.neoforged.neoforge.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 Summary

    Fields
    Modifier and Type
    Field
    Description
    static final it.unimi.dsi.fastutil.longs.Long2ObjectFunction<ModelData>
     
    private final net.minecraft.world.level.Level
     
    private final it.unimi.dsi.fastutil.longs.Long2ObjectMap<it.unimi.dsi.fastutil.longs.Long2ObjectMap<ModelData>>
     
    private final it.unimi.dsi.fastutil.longs.Long2ObjectMap<Set<net.minecraft.core.BlockPos>>
     
    private final Thread
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ModelDataManager(net.minecraft.world.level.Level level)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    getAt(net.minecraft.core.BlockPos pos)
    Retrieves model data for a block at the given position.
    @UnmodifiableView it.unimi.dsi.fastutil.longs.Long2ObjectMap<ModelData>
    getAt(net.minecraft.core.SectionPos pos)
    Provides all the model data for a given chunk section.
    private boolean
     
    static void
     
    private void
    refreshAt(long section)
     
    void
    requestRefresh(net.minecraft.world.level.block.entity.BlockEntity blockEntity)
    Request a refresh of the stored data for the given BlockEntity.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • owningThread

      private final Thread owningThread
    • level

      private final net.minecraft.world.level.Level level
    • needModelDataRefresh

      private final it.unimi.dsi.fastutil.longs.Long2ObjectMap<Set<net.minecraft.core.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(net.minecraft.world.level.Level level)
  • Method Details

    • requestRefresh

      public void requestRefresh(net.minecraft.world.level.block.entity.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(net.minecraft.core.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(net.minecraft.core.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)