Class ModelDataManager
java.lang.Object
net.neoforged.neoforge.model.data.ModelDataManager
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final it.unimi.dsi.fastutil.longs.Long2ObjectFunction<ModelData> private final Levelprivate final it.unimi.dsi.fastutil.longs.Long2ObjectMap<it.unimi.dsi.fastutil.longs.Long2ObjectMap<ModelData>> private final it.unimi.dsi.fastutil.longs.Long2ObjectMap<it.unimi.dsi.fastutil.longs.LongSet> private final Thread -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieves model data for a block at the given position.@UnmodifiableView it.unimi.dsi.fastutil.longs.Long2ObjectMap<ModelData> getAt(SectionPos pos) Provides all the model data for a given chunk section.private booleanstatic voidonChunkUnload(ChunkEvent.Unload event) private voidrefreshAt(long section) voidrequestRefresh(BlockPos pos) Request a refresh of the stored data for the givenBlockPos.voidrequestRefresh(BlockEntity blockEntity) Request a refresh of the stored data for the givenBlockEntity.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.
-
Field Details
-
owningThread
-
level
-
needModelDataRefresh
private final it.unimi.dsi.fastutil.longs.Long2ObjectMap<it.unimi.dsi.fastutil.longs.LongSet> needModelDataRefresh -
modelDataCache
private final it.unimi.dsi.fastutil.longs.Long2ObjectMap<it.unimi.dsi.fastutil.longs.Long2ObjectMap<ModelData>> modelDataCache -
EMPTY_SNAPSHOT
-
-
Constructor Details
-
ModelDataManager
-
-
Method Details
-
requestRefresh
-
requestRefresh
Request a refresh of the stored data for the given
BlockEntity.The given
BlockEntitymust be in the level owning this manager- Parameters:
blockEntity- The block entity to refresh the stored data for
-
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
ModelDatastored for the given chunk section
-
getAt
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.EMPTYif 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 returnModelData.EMPTYfor nonexistent keys. -
refreshAt
private void refreshAt(long section) -
isOtherThread
private boolean isOtherThread() -
onChunkUnload
-