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 p_214982_, LevelStorageSource.LevelStorageAccess p_214983_, com.mojang.datafixers.DataFixer p_214984_, StructureTemplateManager p_214985_, Executor p_214986_, ChunkGenerator p_214987_, int p_214988_, int p_214989_, boolean p_214990_, ChunkProgressListener p_214991_, ChunkStatusUpdateListener p_214992_, Supplier<DimensionDataStorage> p_214993_) -
Method Summary
Modifier and TypeMethodDescriptionvoid
<T> void
addRegionTicket
(TicketType<T> pType, ChunkPos pPos, int pDistance, T pValue) <T> void
addRegionTicket
(TicketType<T> pType, ChunkPos pPos, int pDistance, T pValue, boolean forceTicks) void
blockChanged
(BlockPos pPos) void
void
broadcastAndSend
(Entity pEntity, Packet<?> pPacket) private boolean
chunkAbsent
(ChunkHolder pChunkHolder, int pStatus) private void
void
close()
getChunk
(int pX, int pZ, ChunkStatus pChunkStatus, boolean pRequireChunk) getChunkDebugData
(ChunkPos pChunkPos) getChunkForLighting
(int pChunkX, int pChunkZ) getChunkFuture
(int pX, int pZ, ChunkStatus pChunkStatus, boolean pRequireChunk) private CompletableFuture
<ChunkResult<ChunkAccess>> getChunkFutureMainThread
(int pX, int pZ, ChunkStatus pChunkStatus, boolean pRequireChunk) getChunkNow
(int pChunkX, int pChunkZ) private void
getFullChunk
(long p_8371_, Consumer<LevelChunk> p_8372_) getLevel()
int
int
int
private ChunkHolder
getVisibleChunkIfPresent
(long pChunkPos) boolean
hasChunk
(int pX, int pZ) Checks to see if a chunk exists at x, zboolean
isPositionTicking
(long pChunkPos) void
move
(ServerPlayer pPlayer) void
onLightUpdate
(LightLayer pType, SectionPos pPos) boolean
pollTask()
void
removeEntity
(Entity pEntity) <T> void
removeRegionTicket
(TicketType<T> pType, ChunkPos pPos, int pDistance, T pValue) <T> void
removeRegionTicket
(TicketType<T> pType, ChunkPos pPos, int pDistance, T pValue, boolean forceTicks) void
(package private) boolean
void
save
(boolean pFlush) void
setSimulationDistance
(int pSimulationDistance) void
setSpawnSettings
(boolean pHostile, boolean pPeaceful) void
setViewDistance
(int pViewDistance) private void
storeInCache
(long pChunkPos, ChunkAccess pChunk, ChunkStatus pChunkStatus) void
tick
(BooleanSupplier pHasTimeLeft, boolean pTickChunks) private void
void
updateChunkForced
(ChunkPos pPos, boolean pAdd) 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 p_214982_, LevelStorageSource.LevelStorageAccess p_214983_, com.mojang.datafixers.DataFixer p_214984_, StructureTemplateManager p_214985_, Executor p_214986_, ChunkGenerator p_214987_, int p_214988_, int p_214989_, boolean p_214990_, ChunkProgressListener p_214991_, ChunkStatusUpdateListener p_214992_, Supplier<DimensionDataStorage> p_214993_)
-
-
Method Details
-
getLightEngine
- Specified by:
getLightEngine
in classChunkSource
-
getVisibleChunkIfPresent
-
getTickingGenerated
public int getTickingGenerated() -
storeInCache
-
getChunk
@Nullable public ChunkAccess getChunk(int pX, int pZ, ChunkStatus pChunkStatus, boolean pRequireChunk) - Specified by:
getChunk
in classChunkSource
-
getChunkNow
- Overrides:
getChunkNow
in classChunkSource
-
clearCache
private void clearCache() -
getChunkFuture
public CompletableFuture<ChunkResult<ChunkAccess>> getChunkFuture(int pX, int pZ, ChunkStatus pChunkStatus, boolean pRequireChunk) -
getChunkFutureMainThread
private CompletableFuture<ChunkResult<ChunkAccess>> getChunkFutureMainThread(int pX, int pZ, ChunkStatus pChunkStatus, boolean pRequireChunk) -
chunkAbsent
-
hasChunk
public boolean hasChunk(int pX, int pZ) 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 pChunkPos) -
save
public void save(boolean pFlush) -
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> pType, ChunkPos pPos, int pDistance, T pValue, boolean forceTicks) -
removeRegionTicket
-
removeRegionTicket
public <T> void removeRegionTicket(TicketType<T> pType, ChunkPos pPos, int pDistance, T pValue, boolean forceTicks) -
updateChunkForced
- Overrides:
updateChunkForced
in classChunkSource
-
move
-
removeEntity
-
addEntity
-
broadcastAndSend
-
broadcast
-
setViewDistance
public void setViewDistance(int pViewDistance) -
setSimulationDistance
public void setSimulationDistance(int pSimulationDistance) -
setSpawnSettings
public void setSpawnSettings(boolean pHostile, boolean pPeaceful) - Overrides:
setSpawnSettings
in classChunkSource
-
getChunkDebugData
-
getDataStorage
-
getPoiManager
-
chunkScanner
-
getLastSpawnState
-
removeTicketsOnClosing
public void removeTicketsOnClosing()
-