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) final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private final Set
<ChunkHolder> 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
private static final org.slf4j.Logger
(package private) final Thread
private final ServerChunkCache.MainThreadExecutor
private boolean
private boolean
private final List
<LevelChunk> private final TicketStorage
-
Constructor Summary
ConstructorsConstructorDescriptionServerChunkCache
(ServerLevel pLevel, LevelStorageSource.LevelStorageAccess pLevelStorageAccess, com.mojang.datafixers.DataFixer pFixerUpper, StructureTemplateManager pStructureManager, Executor pDispatcher, ChunkGenerator pGenerator, int pViewDistance, int pSimulationDistance, boolean pSync, ChunkProgressListener pProgressListener, ChunkStatusUpdateListener pChunkStatusListener, Supplier<DimensionDataStorage> pOverworldDataStorage) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
addTicketWithRadius
(TicketType pTicket, ChunkPos pChunkPos, int pRadius) void
blockChanged
(BlockPos pPos) void
void
broadcastAndSend
(Entity pEntity, Packet<?> pPacket) private void
broadcastChangedChunks
(ProfilerFiller pProfiler) private boolean
chunkAbsent
(ChunkHolder pChunkHolder, int pStatus) private void
void
close()
void
getChunk
(int p_8360_, int p_8361_, ChunkStatus p_330876_, boolean p_8363_) getChunkDebugData
(ChunkPos pChunkPos) getChunkForLighting
(int p_8454_, int p_8455_) 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) it.unimi.dsi.fastutil.longs.LongSet
private void
getFullChunk
(long pChunkPos, Consumer<LevelChunk> pFullChunkGetter) 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
onChunkReadyToSend
(ChunkHolder pChunkHolder) void
onLightUpdate
(LightLayer pType, SectionPos pPos) boolean
pollTask()
void
removeEntity
(Entity pEntity) void
removeTicketWithRadius
(TicketType pTicket, ChunkPos pChunkPos, int pRadius) (package private) boolean
void
save
(boolean pFlush) void
setSimulationDistance
(int pSimulationDistance) void
setSpawnSettings
(boolean p_8425_) void
setViewDistance
(int pViewDistance) private void
storeInCache
(long pChunkPos, ChunkAccess pChunk, ChunkStatus pChunkStatus) void
tick
(BooleanSupplier p_201913_, boolean p_201914_) private void
private void
tickChunks
(ProfilerFiller pProfiler, long pTimeInhabited) private void
tickSpawningChunk
(LevelChunk pChunk, long pTimeInhabited, List<MobCategory> pSpawnCategories, NaturalSpawner.SpawnState pSpawnState) boolean
updateChunkForced
(ChunkPos p_8400_, boolean p_8401_) Methods inherited from class net.minecraft.world.level.chunk.ChunkSource
getChunk, onSectionEmptinessChanged
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
-
LOGGER
private static final org.slf4j.Logger LOGGER -
distanceManager
-
level
-
mainThread
-
lightEngine
-
mainThreadProcessor
-
chunkMap
-
dataStorage
-
ticketStorage
-
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
-
spawningChunks
-
chunkHoldersToBroadcast
-
lastSpawnState
-
-
Constructor Details
-
ServerChunkCache
public ServerChunkCache(ServerLevel pLevel, LevelStorageSource.LevelStorageAccess pLevelStorageAccess, com.mojang.datafixers.DataFixer pFixerUpper, StructureTemplateManager pStructureManager, Executor pDispatcher, ChunkGenerator pGenerator, int pViewDistance, int pSimulationDistance, boolean pSync, ChunkProgressListener pProgressListener, ChunkStatusUpdateListener pChunkStatusListener, Supplier<DimensionDataStorage> pOverworldDataStorage)
-
-
Method Details
-
getLightEngine
- Specified by:
getLightEngine
in classChunkSource
-
getVisibleChunkIfPresent
-
getTickingGenerated
public int getTickingGenerated() -
storeInCache
-
getChunk
@Nullable public ChunkAccess getChunk(int p_8360_, int p_8361_, ChunkStatus p_330876_, boolean p_8363_) - 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() -
broadcastChangedChunks
-
tickChunks
-
tickSpawningChunk
private void tickSpawningChunk(LevelChunk pChunk, long pTimeInhabited, List<MobCategory> pSpawnCategories, NaturalSpawner.SpawnState pSpawnState) -
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
-
addTicket
-
addTicketWithRadius
-
removeTicketWithRadius
-
updateChunkForced
- Overrides:
updateChunkForced
in classChunkSource
-
getForceLoadedChunks
public it.unimi.dsi.fastutil.longs.LongSet getForceLoadedChunks()- Overrides:
getForceLoadedChunks
in classChunkSource
-
move
-
removeEntity
-
addEntity
-
broadcastAndSend
-
broadcast
-
setViewDistance
public void setViewDistance(int pViewDistance) -
setSimulationDistance
public void setSimulationDistance(int pSimulationDistance) -
setSpawnSettings
public void setSpawnSettings(boolean p_8425_) - Overrides:
setSpawnSettings
in classChunkSource
-
getChunkDebugData
-
getDataStorage
-
getPoiManager
-
chunkScanner
-
getLastSpawnState
-
deactivateTicketsOnClosing
public void deactivateTicketsOnClosing() -
onChunkReadyToSend
-