Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Latest commit

 

History

History
29 lines (23 loc) · 980 Bytes

lightloader.md

File metadata and controls

29 lines (23 loc) · 980 Bytes
description
This page describes how to add lighting to a minestom instance

Setting the chunk supplier

To use the LightingChunk class, you can call the InstanceContainer#setChunkSupplier(LightingChunk::new) method. By default lighting will be generated for chunks when they are sent to the client.

An example of using this method:

InstanceContainer.setChunkSupplier(LightingChunk::new);

Precalculating Lighting

To load preload chunks and calculate lighting before players join, you can use the following code:

var chunks = new ArrayList<CompletableFuture<Chunk>>();
ChunkUtils.forChunksInRange(0, 0, 32, (x, z) -> chunks.add(instanceContainer.loadChunk(x, z)));

CompletableFuture.runAsync(() -> {
    CompletableFuture.allOf(chunks.toArray(CompletableFuture[]::new)).join();
    System.out.println("load end");
    LightingChunk.relight(instanceContainer, instanceContainer.getChunks());
    System.out.println("light end");
});