Class ModelDataManager
java.lang.Object
net.neoforged.neoforge.model.data.ModelDataManager
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
FieldsModifier and TypeFieldDescriptionstatic 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 -
Method Summary
Modifier and TypeMethodDescriptiongetAt
(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
onChunkUnload
(ChunkEvent.Unload event) private void
refreshAt
(long section) void
requestRefresh
(net.minecraft.world.level.block.entity.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
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
-
-
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 givenBlockEntity
. The givenBlockEntity
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
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 returnModelData.EMPTY
for nonexistent keys. -
refreshAt
private void refreshAt(long section) -
isOtherThread
private boolean isOtherThread() -
onChunkUnload
-