Skip to content

Instantly share code, notes, and snippets.

@CutestNekoAqua
Last active January 2, 2022 21:24
Show Gist options
  • Save CutestNekoAqua/688ad6240ce7c4fd83c208d66616b965 to your computer and use it in GitHub Desktop.
Save CutestNekoAqua/688ad6240ce7c4fd83c208d66616b965 to your computer and use it in GitHub Desktop.

request light engine, don't wait for response invalidate packet on update

  • High Level light api - chunk based: (look at batching from new chunk gen branch)
public class FullBrightLightGenerator implements LightGenerator {

@Override
public void lightChunk(ChunkLightBatch batch) {
    int offX = chunk.getX() * 16;
    int offY = chunk.getY() * 16;
    for (int x = 0; x < Chunk.SIZE_X; x++) {
        for (int y = 0; y < chunk.getYSize(); y++) {
            for (int z = 0; z < Chunk.SIZE_X; z++) {
	                boolean blockAboveIsAir = batch.get(x, y + 1, z).compare(Block.AIR);
	                batch.set(offX + x, y, offZ + z, blockIsAir ? LightType.SKY : LightType.BLOCK, 15);
	            }
	        }
	    }
	};
}

low level api by engine supplying byte array

Interface for requesting to generate light chunk wise, section wise, and block wise, with having a defaultLightEngine in MinecraftServer and a customLightEngine in InstanceContainer

passing a Optional of locations of pre-existing light sources to the light engine, when the chunk gen is smart enough to recognize light sources on generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment