Skip to content

Commit

Permalink
feat(ExamplePlugin): show loaded and loading chunk count
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed May 18, 2024
1 parent 622683d commit 87fc098
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,9 @@ public interface ChunkService extends ChunkAccessible {

void forEachLoadedChunks(Consumer<Chunk> consumer);

@UnmodifiableView
Collection<Chunk> getLoadedChunks();

@UnmodifiableView
Collection<CompletableFuture<Chunk>> getLoadingChunks();
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ private void onPlayerInitialized(PlayerInitializedEvent event) {
int cx = chunk.getX();
int cz = chunk.getZ();
list.add("Chunk: §a" + cx + ", " + cz);
list.add("Loaded: §a" + player.getDimension().getChunkService().getLoadedChunks().size());
list.add("Loading: §a" + player.getDimension().getChunkService().getLoadingChunks().size());
list.add("Biome: §a" + player.getCurrentChunk().getBiome((int) loc.x() & 15, (int) loc.y(), (int) loc.z() & 15));
scoreboard.setLines(list);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,15 @@ public void forEachLoadedChunks(Consumer<Chunk> consumer) {
}

@Override
@UnmodifiableView
public Collection<Chunk> getLoadedChunks() {
return loadedChunks.values();
return Collections.unmodifiableCollection(loadedChunks.values());
}

@Override
@UnmodifiableView
public Collection<CompletableFuture<Chunk>> getLoadingChunks() {
return Collections.unmodifiableCollection(loadingChunks.values());
}

public void unloadChunk(int x, int z) {
Expand Down

0 comments on commit 87fc098

Please sign in to comment.