public class ServerChunkManager extends ChunkManager
Modifier and Type | Class and Description |
---|---|
(package private) class |
ServerChunkManager.MainThreadExecutor |
Modifier and Type | Field and Description |
---|---|
private static List<ChunkStatus> |
CHUNK_STATUSES |
private Chunk[] |
chunkCache |
private ChunkGenerator |
chunkGenerator |
private long[] |
chunkPosCache |
private ChunkStatus[] |
chunkStatusCache |
private long |
lastMobSpawningTime |
private ServerLightingProvider |
lightProvider |
private ServerChunkManager.MainThreadExecutor |
mainThreadExecutor |
private PersistentStateManager |
persistentStateManager |
private Thread |
serverThread |
private boolean |
spawnAnimals |
private SpawnHelper.Info |
spawnEntry |
private boolean |
spawnMonsters |
ThreadedAnvilChunkStorage |
threadedAnvilChunkStorage |
private ChunkTicketManager |
ticketManager |
private ServerWorld |
world |
Constructor and Description |
---|
ServerChunkManager(ServerWorld serverWorld,
LevelStorage.Session session,
com.mojang.datafixers.DataFixer dataFixer,
StructureManager structureManager,
Executor workerExecutor,
ChunkGenerator chunkGenerator,
int viewDistance,
boolean bool,
WorldGenerationProgressListener worldGenerationProgressListener,
Supplier<PersistentStateManager> supplier) |
Modifier and Type | Method and Description |
---|---|
<T> void |
addTicket(ChunkTicketType<T> ticketType,
ChunkPos pos,
int radius,
T argument)
Adds a chunk ticket to the ticket manager.
|
void |
applyViewDistance(int watchDistance) |
void |
close() |
boolean |
executeQueuedTasks() |
BlockView |
getChunk(int chunkX,
int chunkZ) |
Chunk |
getChunk(int x,
int z,
ChunkStatus leastStatus,
boolean create) |
private CompletableFuture<com.mojang.datafixers.util.Either<Chunk,ChunkHolder.Unloaded>> |
getChunkFuture(int chunkX,
int chunkZ,
ChunkStatus leastStatus,
boolean create) |
CompletableFuture<com.mojang.datafixers.util.Either<Chunk,ChunkHolder.Unloaded>> |
getChunkFutureSyncOnMainThread(int chunkX,
int chunkZ,
ChunkStatus leastStatus,
boolean create) |
ChunkGenerator |
getChunkGenerator() |
private ChunkHolder |
getChunkHolder(long pos) |
String |
getChunkLoadingDebugInfo(ChunkPos chunkPos) |
String |
getDebugString() |
ServerLightingProvider |
getLightingProvider() |
int |
getLoadedChunkCount() |
int |
getPendingTasks() |
PersistentStateManager |
getPersistentStateManager() |
PointOfInterestStorage |
getPointOfInterestStorage() |
SpawnHelper.Info |
getSpawnInfo() |
int |
getTotalChunksLoadedCount() |
World |
getWorld() |
WorldChunk |
getWorldChunk(int chunkX,
int chunkZ) |
private void |
ifChunkLoaded(long pos,
Consumer<WorldChunk> chunkConsumer) |
private void |
initChunkCaches() |
boolean |
isChunkLoaded(int x,
int z) |
private boolean |
isFutureReady(long pos,
Function<ChunkHolder,CompletableFuture<com.mojang.datafixers.util.Either<WorldChunk,ChunkHolder.Unloaded>>> futureFunction) |
private boolean |
isMissingForLevel(ChunkHolder holder,
int maxLevel) |
void |
loadEntity(Entity entity) |
void |
markForUpdate(BlockPos pos) |
void |
onLightUpdate(LightType type,
ChunkSectionPos pos) |
private void |
putInCache(long pos,
Chunk chunk,
ChunkStatus status) |
<T> void |
removeTicket(ChunkTicketType<T> ticketType,
ChunkPos pos,
int radius,
T argument)
Removes a chunk ticket from the ticket manager.
|
void |
save(boolean flush) |
void |
sendToNearbyPlayers(Entity entity,
Packet<?> packet) |
void |
sendToOtherNearbyPlayers(Entity entity,
Packet<?> packet) |
void |
setChunkForced(ChunkPos pos,
boolean forced) |
void |
setMobSpawnOptions(boolean spawnMonsters,
boolean spawnAnimals) |
boolean |
shouldTickBlock(BlockPos pos) |
boolean |
shouldTickChunk(ChunkPos pos) |
boolean |
shouldTickEntity(Entity entity) |
private boolean |
tick() |
void |
tick(BooleanSupplier shouldKeepTicking) |
private void |
tickChunks() |
void |
unloadEntity(Entity entity) |
void |
updateCameraPosition(ServerPlayerEntity player) |
getWorldChunk
private static final List<ChunkStatus> CHUNK_STATUSES
private final ChunkTicketManager ticketManager
private final ChunkGenerator chunkGenerator
private final ServerWorld world
private final Thread serverThread
private final ServerLightingProvider lightProvider
private final ServerChunkManager.MainThreadExecutor mainThreadExecutor
public final ThreadedAnvilChunkStorage threadedAnvilChunkStorage
private final PersistentStateManager persistentStateManager
private long lastMobSpawningTime
private boolean spawnMonsters
private boolean spawnAnimals
private final long[] chunkPosCache
private final ChunkStatus[] chunkStatusCache
private final Chunk[] chunkCache
@Nullable private SpawnHelper.Info spawnEntry
public ServerChunkManager(ServerWorld serverWorld, LevelStorage.Session session, com.mojang.datafixers.DataFixer dataFixer, StructureManager structureManager, Executor workerExecutor, ChunkGenerator chunkGenerator, int viewDistance, boolean bool, WorldGenerationProgressListener worldGenerationProgressListener, Supplier<PersistentStateManager> supplier)
public ServerLightingProvider getLightingProvider()
getLightingProvider
in class ChunkManager
@Nullable private ChunkHolder getChunkHolder(long pos)
public int getTotalChunksLoadedCount()
private void putInCache(long pos, Chunk chunk, ChunkStatus status)
@Nullable public Chunk getChunk(int x, int z, ChunkStatus leastStatus, boolean create)
getChunk
in class ChunkManager
@Nullable public WorldChunk getWorldChunk(int chunkX, int chunkZ)
getWorldChunk
in class ChunkManager
private void initChunkCaches()
@Environment(value=CLIENT) public CompletableFuture<com.mojang.datafixers.util.Either<Chunk,ChunkHolder.Unloaded>> getChunkFutureSyncOnMainThread(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create)
private CompletableFuture<com.mojang.datafixers.util.Either<Chunk,ChunkHolder.Unloaded>> getChunkFuture(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create)
private boolean isMissingForLevel(@Nullable ChunkHolder holder, int maxLevel)
public boolean isChunkLoaded(int x, int z)
isChunkLoaded
in class ChunkManager
public BlockView getChunk(int chunkX, int chunkZ)
getChunk
in interface ChunkProvider
getChunk
in class ChunkManager
public World getWorld()
public boolean executeQueuedTasks()
private boolean tick()
public boolean shouldTickEntity(Entity entity)
shouldTickEntity
in class ChunkManager
public boolean shouldTickChunk(ChunkPos pos)
shouldTickChunk
in class ChunkManager
public boolean shouldTickBlock(BlockPos pos)
shouldTickBlock
in class ChunkManager
private boolean isFutureReady(long pos, Function<ChunkHolder,CompletableFuture<com.mojang.datafixers.util.Either<WorldChunk,ChunkHolder.Unloaded>>> futureFunction)
public void save(boolean flush)
public void close() throws IOException
close
in interface AutoCloseable
close
in class ChunkManager
IOException
public void tick(BooleanSupplier shouldKeepTicking)
private void tickChunks()
private void ifChunkLoaded(long pos, Consumer<WorldChunk> chunkConsumer)
public String getDebugString()
getDebugString
in class ChunkManager
public int getPendingTasks()
public ChunkGenerator getChunkGenerator()
public int getLoadedChunkCount()
public void markForUpdate(BlockPos pos)
public void onLightUpdate(LightType type, ChunkSectionPos pos)
public <T> void addTicket(ChunkTicketType<T> ticketType, ChunkPos pos, int radius, T argument)
Addition of a ticket may load chunk(s) at some point in the future depending on the loading level in the ticket's vicinity.
public <T> void removeTicket(ChunkTicketType<T> ticketType, ChunkPos pos, int radius, T argument)
Removal of a ticket may unload chunk(s) at some point in the future depending on the loading levels in the ticket's vicinity after removal.
public void setChunkForced(ChunkPos pos, boolean forced)
setChunkForced
in class ChunkManager
public void updateCameraPosition(ServerPlayerEntity player)
public void unloadEntity(Entity entity)
public void loadEntity(Entity entity)
public void applyViewDistance(int watchDistance)
public void setMobSpawnOptions(boolean spawnMonsters, boolean spawnAnimals)
setMobSpawnOptions
in class ChunkManager
@Environment(value=CLIENT) public String getChunkLoadingDebugInfo(ChunkPos chunkPos)
public PersistentStateManager getPersistentStateManager()
public PointOfInterestStorage getPointOfInterestStorage()
@Nullable public SpawnHelper.Info getSpawnInfo()