Package net.minecraft.server.level
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 ClassesModifier and TypeClassDescription(package private) static final record
(package private) final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private static final List
<ChunkStatus> final ChunkMap
private final DimensionDataStorage
private final DistanceManager
private final ChunkAccess[]
private final long[]
private final ChunkStatus[]
private long
private NaturalSpawner.SpawnState
final ServerLevel
(package private) final ThreadedLevelLightEngine
(package private) final Thread
private final ServerChunkCache.MainThreadExecutor
private boolean
private boolean
-
Constructor Summary
ConstructorsConstructorDescriptionServerChunkCache
(ServerLevel level, LevelStorageSource.LevelStorageAccess levelStorageAccess, com.mojang.datafixers.DataFixer fixerUpper, StructureTemplateManager structureManager, Executor dispatcher, ChunkGenerator generator, int viewDistance, int simulationDistance, boolean sync, ChunkProgressListener progressListener, ChunkStatusUpdateListener chunkStatusListener, Supplier<DimensionDataStorage> overworldDataStorage) -
Method Summary
Modifier and TypeMethodDescriptionvoid
<T> void
addRegionTicket
(TicketType<T> type, ChunkPos pos, int distance, T value) <T> void
addRegionTicket
(TicketType<T> type, ChunkPos pos, int distance, T value, boolean forceTicks) void
blockChanged
(BlockPos pos) void
void
broadcastAndSend
(Entity entity, Packet<?> packet) private boolean
chunkAbsent
(ChunkHolder chunkHolder, int status) private void
void
close()
getChunk
(int x, int z, ChunkStatus chunkStatus, boolean requireChunk) getChunkDebugData
(ChunkPos chunkPos) getChunkForLighting
(int chunkX, int chunkZ) getChunkFuture
(int x, int z, ChunkStatus chunkStatus, boolean requireChunk) private CompletableFuture
<ChunkResult<ChunkAccess>> getChunkFutureMainThread
(int x, int z, ChunkStatus chunkStatus, boolean requireChunk) getChunkNow
(int chunkX, int chunkZ) private void
getFullChunk
(long chunkPos, Consumer<LevelChunk> fullChunkGetter) getLevel()
int
int
int
private ChunkHolder
getVisibleChunkIfPresent
(long chunkPos) boolean
hasChunk
(int x, int z) Checks to see if a chunk exists at x, zboolean
isPositionTicking
(long chunkPos) void
move
(ServerPlayer player) void
onLightUpdate
(LightLayer type, SectionPos pos) boolean
pollTask()
void
removeEntity
(Entity entity) <T> void
removeRegionTicket
(TicketType<T> type, ChunkPos pos, int distance, T value) <T> void
removeRegionTicket
(TicketType<T> type, ChunkPos pos, int distance, T value, boolean forceTicks) void
(package private) boolean
void
save
(boolean flush) void
setSimulationDistance
(int simulationDistance) void
setSpawnSettings
(boolean hostile, boolean peaceful) void
setViewDistance
(int viewDistance) private void
storeInCache
(long chunkPos, ChunkAccess chunk, ChunkStatus chunkStatus) void
tick
(BooleanSupplier hasTimeLeft, boolean tickChunks) private void
void
updateChunkForced
(ChunkPos pos, boolean add) Methods inherited from class net.minecraft.world.level.chunk.ChunkSource
getChunk
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.neoforged.neoforge.common.extensions.IServerChunkCacheExtension
broadcast, broadcastAndSend, self
-
Field Details
-
CHUNK_STATUSES
-
distanceManager
-
level
-
mainThread
-
lightEngine
-
mainThreadProcessor
-
chunkMap
-
dataStorage
-
lastInhabitedUpdate
private long lastInhabitedUpdate -
spawnEnemies
private boolean spawnEnemies -
spawnFriendlies
private boolean spawnFriendlies -
CACHE_SIZE
private static final int CACHE_SIZE- See Also:
-
lastChunkPos
private final long[] lastChunkPos -
lastChunkStatus
-
lastChunk
-
lastSpawnState
-
-
Constructor Details
-
ServerChunkCache
public ServerChunkCache(ServerLevel level, LevelStorageSource.LevelStorageAccess levelStorageAccess, com.mojang.datafixers.DataFixer fixerUpper, StructureTemplateManager structureManager, Executor dispatcher, ChunkGenerator generator, int viewDistance, int simulationDistance, boolean sync, ChunkProgressListener progressListener, ChunkStatusUpdateListener chunkStatusListener, Supplier<DimensionDataStorage> overworldDataStorage)
-
-
Method Details
-
getLightEngine
- Specified by:
getLightEngine
in classChunkSource
-
getVisibleChunkIfPresent
-
getTickingGenerated
public int getTickingGenerated() -
storeInCache
-
getChunk
- Specified by:
getChunk
in classChunkSource
-
getChunkNow
- Overrides:
getChunkNow
in classChunkSource
-
clearCache
private void clearCache() -
getChunkFuture
public CompletableFuture<ChunkResult<ChunkAccess>> getChunkFuture(int x, int z, ChunkStatus chunkStatus, boolean requireChunk) -
getChunkFutureMainThread
private CompletableFuture<ChunkResult<ChunkAccess>> getChunkFutureMainThread(int x, int z, ChunkStatus chunkStatus, boolean requireChunk) -
chunkAbsent
-
hasChunk
public boolean hasChunk(int x, int z) Checks to see if a chunk exists at x, z- Overrides:
hasChunk
in classChunkSource
- Returns:
true
if a chunk is loaded at the provided position, without forcing a chunk load.
-
getChunkForLighting
- Specified by:
getChunkForLighting
in interfaceLightChunkGetter
- Overrides:
getChunkForLighting
in classChunkSource
-
getLevel
- Specified by:
getLevel
in interfaceLightChunkGetter
-
pollTask
public boolean pollTask() -
runDistanceManagerUpdates
boolean runDistanceManagerUpdates() -
isPositionTicking
public boolean isPositionTicking(long chunkPos) -
save
public void save(boolean flush) -
close
- Specified by:
close
in interfaceAutoCloseable
- Overrides:
close
in classChunkSource
- Throws:
IOException
-
tick
- Specified by:
tick
in classChunkSource
-
tickChunks
private void tickChunks() -
getFullChunk
-
gatherStats
- Specified by:
gatherStats
in classChunkSource
-
getPendingTasksCount
public int getPendingTasksCount() -
getGenerator
-
getGeneratorState
-
randomState
-
getLoadedChunksCount
public int getLoadedChunksCount()- Specified by:
getLoadedChunksCount
in classChunkSource
-
blockChanged
-
onLightUpdate
- Specified by:
onLightUpdate
in interfaceLightChunkGetter
-
addRegionTicket
-
addRegionTicket
public <T> void addRegionTicket(TicketType<T> type, ChunkPos pos, int distance, T value, boolean forceTicks) -
removeRegionTicket
-
removeRegionTicket
public <T> void removeRegionTicket(TicketType<T> type, ChunkPos pos, int distance, T value, boolean forceTicks) -
updateChunkForced
- Overrides:
updateChunkForced
in classChunkSource
-
move
-
removeEntity
-
addEntity
-
broadcastAndSend
-
broadcast
-
setViewDistance
public void setViewDistance(int viewDistance) -
setSimulationDistance
public void setSimulationDistance(int simulationDistance) -
setSpawnSettings
public void setSpawnSettings(boolean hostile, boolean peaceful) - Overrides:
setSpawnSettings
in classChunkSource
-
getChunkDebugData
-
getDataStorage
-
getPoiManager
-
chunkScanner
-
getLastSpawnState
-
removeTicketsOnClosing
public void removeTicketsOnClosing()
-