From b119425c8e75f425c4458c026637603ca4bcbbed Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Mon, 16 Oct 2023 18:52:28 -0700 Subject: [PATCH] Fix mushrooms not generating in swamps During feature generation, light data is not initialised and will always return 15 in Starlight. Vanilla can possibly return 0 if partially initialised, which allows some mushroom blocks to generate. In general, the brightness value from the light engine should not be used until the chunk is ready. To emulate Vanilla behavior better, we return 0 as the brightness during world gen unless the target chunk is finished lighting. The regular light retrieval outside of WorldGenRegion remains the same, as behaviorally chunks not lit should be at max skylight and zero block light. --- patches/server/Starlight.patch | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/patches/server/Starlight.patch b/patches/server/Starlight.patch index a272fd3d25..8c44f1ab45 100644 --- a/patches/server/Starlight.patch +++ b/patches/server/Starlight.patch @@ -4850,6 +4850,38 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public static TicketType create(String name, Comparator argumentComparator) { return new TicketType<>(name, argumentComparator, 0L); +diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java ++++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java +@@ -0,0 +0,0 @@ public class WorldGenRegion implements WorldGenLevel { + } + } + ++ // Paper start - starlight ++ @Override ++ public int getBrightness(final net.minecraft.world.level.LightLayer lightLayer, final BlockPos blockPos) { ++ final ChunkAccess chunk = this.getChunk(blockPos.getX() >> 4, blockPos.getZ() >> 4); ++ if (!chunk.isLightCorrect()) { ++ return 0; ++ } ++ return this.getLightEngine().getLayerListener(lightLayer).getLightValue(blockPos); ++ } ++ ++ ++ @Override ++ public int getRawBrightness(final BlockPos blockPos, final int subtract) { ++ final ChunkAccess chunk = this.getChunk(blockPos.getX() >> 4, blockPos.getZ() >> 4); ++ if (!chunk.isLightCorrect()) { ++ return 0; ++ } ++ return this.getLightEngine().getRawBrightness(blockPos, subtract); ++ } ++ // Paper end - starlight ++ + public boolean isOldChunkAround(ChunkPos chunkPos, int checkRadius) { + return this.level.getChunkSource().chunkMap.isOldChunkAround(chunkPos, checkRadius); + } diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java