Class ServerChunkCache
java.lang.Object
net.minecraft.world.level.chunk.ChunkSource
net.minecraft.server.level.ServerChunkCache
- All Implemented Interfaces:
AutoCloseable, LightChunkGetter, IServerChunkCacheExtension
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate final Set<ChunkHolder> final ChunkMapprivate final DistanceManagerprivate final @Nullable ChunkAccess[]private final long[]private final @Nullable ChunkStatus[]private longprivate @Nullable NaturalSpawner.SpawnStatefinal ServerLevelprivate final ThreadedLevelLightEngineprivate static final org.slf4j.Loggerprivate final Threadprivate final ServerChunkCache.MainThreadExecutorprivate final SavedDataStorageprivate booleanprivate final List<LevelChunk> private final TicketStorage -
Constructor Summary
ConstructorsConstructorDescriptionServerChunkCache(ServerLevel level, LevelStorageSource.LevelStorageAccess levelStorage, com.mojang.datafixers.DataFixer fixerUpper, StructureTemplateManager structureTemplateManager, Executor executor, ChunkGenerator generator, int viewDistance, int simulationDistance, boolean syncWrites, ChunkStatusUpdateListener chunkStatusListener, Supplier<SavedDataStorage> overworldDataStorage) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddTicketAndLoadWithRadius(TicketType type, ChunkPos pos, int radius) voidaddTicketWithRadius(TicketType type, ChunkPos pos, int radius) voidblockChanged(BlockPos pos) private voidbroadcastChangedChunks(ProfilerFiller profiler) private booleanchunkAbsent(@Nullable ChunkHolder chunkHolder, int targetTicketLevel) private voidvoidclose()void@Nullable ChunkAccessgetChunk(int x, int z, ChunkStatus targetStatus, boolean loadOrGenerate) @Nullable LightChunkgetChunkForLighting(int x, int z) getChunkFuture(int x, int z, ChunkStatus targetStatus, boolean loadOrGenerate) private CompletableFuture<ChunkResult<ChunkAccess>> getChunkFutureMainThread(int x, int z, ChunkStatus targetStatus, boolean loadOrGenerate) @Nullable LevelChunkgetChunkNow(int x, int z) it.unimi.dsi.fastutil.longs.LongSetprivate voidgetFullChunk(long chunkKey, Consumer<LevelChunk> output) @Nullable NaturalSpawner.SpawnStategetLevel()intintprivate @Nullable ChunkHoldergetVisibleChunkIfPresent(long key) booleanbooleanhasChunk(int x, int z) Checks to see if a chunk exists at x, zbooleanisPositionTicking(long chunkKey) voidmove(ServerPlayer player) voidonChunkReadyToSend(ChunkHolder chunk) voidonLightUpdate(LightLayer layer, SectionPos pos) booleanpollTask()voidremoveEntity(Entity entity) voidremoveTicketWithRadius(TicketType type, ChunkPos pos, int radius) (package private) booleanvoidsave(boolean flushStorage) voidsendToTrackingPlayers(Entity entity, Packet<? super ClientGamePacketListener> packet) voidsendToTrackingPlayersAndSelf(Entity entity, Packet<? super ClientGamePacketListener> packet) voidsetSimulationDistance(int simulationDistance) voidsetSpawnSettings(boolean spawnEnemies) voidsetViewDistance(int newDistance) private voidstoreInCache(long pos, @Nullable ChunkAccess chunk, ChunkStatus status) voidtick(BooleanSupplier haveTime, boolean tickChunks) private voidprivate voidtickChunks(ProfilerFiller profiler, long timeDiff) private voidtickSpawningChunk(LevelChunk chunk, long timeDiff, List<MobCategory> spawningCategories, NaturalSpawner.SpawnState spawnCookie) booleanupdateChunkForced(ChunkPos pos, boolean forced) Methods inherited from class ChunkSource
getChunk, onSectionEmptinessChangedMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface IServerChunkCacheExtension
self, sendToTrackingPlayers, sendToTrackingPlayersAndSelf
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
distanceManager
-
level
-
mainThread
-
lightEngine
-
mainThreadProcessor
-
chunkMap
-
savedDataStorage
-
ticketStorage
-
lastInhabitedUpdate
private long lastInhabitedUpdate -
spawnEnemies
private boolean spawnEnemies -
CACHE_SIZE
private static final int CACHE_SIZE- See Also:
-
lastChunkPos
private final long[] lastChunkPos -
lastChunkStatus
-
lastChunk
-
spawningChunks
-
chunkHoldersToBroadcast
-
lastSpawnState
-
-
Constructor Details
-
ServerChunkCache
public ServerChunkCache(ServerLevel level, LevelStorageSource.LevelStorageAccess levelStorage, com.mojang.datafixers.DataFixer fixerUpper, StructureTemplateManager structureTemplateManager, Executor executor, ChunkGenerator generator, int viewDistance, int simulationDistance, boolean syncWrites, ChunkStatusUpdateListener chunkStatusListener, Supplier<SavedDataStorage> overworldDataStorage)
-
-
Method Details
-
getLightEngine
- Specified by:
getLightEnginein classChunkSource
-
getVisibleChunkIfPresent
-
storeInCache
-
getChunk
public @Nullable ChunkAccess getChunk(int x, int z, ChunkStatus targetStatus, boolean loadOrGenerate) - Specified by:
getChunkin classChunkSource
-
getChunkNow
- Overrides:
getChunkNowin classChunkSource
-
clearCache
private void clearCache() -
getChunkFuture
public CompletableFuture<ChunkResult<ChunkAccess>> getChunkFuture(int x, int z, ChunkStatus targetStatus, boolean loadOrGenerate) -
getChunkFutureMainThread
private CompletableFuture<ChunkResult<ChunkAccess>> getChunkFutureMainThread(int x, int z, ChunkStatus targetStatus, boolean loadOrGenerate) -
chunkAbsent
-
hasChunk
public boolean hasChunk(int x, int z) Checks to see if a chunk exists at x, z- Overrides:
hasChunkin classChunkSource- Returns:
trueif a chunk is loaded at the provided position, without forcing a chunk load.
-
getChunkForLighting
- Specified by:
getChunkForLightingin interfaceLightChunkGetter- Overrides:
getChunkForLightingin classChunkSource
-
getLevel
- Specified by:
getLevelin interfaceLightChunkGetter
-
pollTask
public boolean pollTask() -
runDistanceManagerUpdates
boolean runDistanceManagerUpdates() -
isPositionTicking
public boolean isPositionTicking(long chunkKey) -
save
public void save(boolean flushStorage) -
close
- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classChunkSource- Throws:
IOException
-
tick
- Specified by:
tickin classChunkSource
-
tickChunks
private void tickChunks() -
broadcastChangedChunks
-
tickChunks
-
tickSpawningChunk
private void tickSpawningChunk(LevelChunk chunk, long timeDiff, List<MobCategory> spawningCategories, NaturalSpawner.SpawnState spawnCookie) -
getFullChunk
-
gatherStats
- Specified by:
gatherStatsin classChunkSource
-
getPendingTasksCount
public int getPendingTasksCount() -
getGenerator
-
getGeneratorState
-
randomState
-
getLoadedChunksCount
public int getLoadedChunksCount()- Specified by:
getLoadedChunksCountin classChunkSource
-
blockChanged
-
onLightUpdate
- Specified by:
onLightUpdatein interfaceLightChunkGetter
-
hasActiveTickets
public boolean hasActiveTickets() -
addTicket
-
addTicketAndLoadWithRadius
-
addTicketWithRadius
-
removeTicketWithRadius
-
updateChunkForced
- Overrides:
updateChunkForcedin classChunkSource
-
getForceLoadedChunks
public it.unimi.dsi.fastutil.longs.LongSet getForceLoadedChunks()- Overrides:
getForceLoadedChunksin classChunkSource
-
move
-
removeEntity
-
addEntity
-
sendToTrackingPlayersAndSelf
public void sendToTrackingPlayersAndSelf(Entity entity, Packet<? super ClientGamePacketListener> packet) -
sendToTrackingPlayers
-
setViewDistance
public void setViewDistance(int newDistance) -
setSimulationDistance
public void setSimulationDistance(int simulationDistance) -
setSpawnSettings
public void setSpawnSettings(boolean spawnEnemies) - Overrides:
setSpawnSettingsin classChunkSource
-
getChunkDebugData
-
getDataStorage
-
getPoiManager
-
chunkScanner
-
getLastSpawnState
-
deactivateTicketsOnClosing
public void deactivateTicketsOnClosing() -
onChunkReadyToSend
-