diff options
author | Spottedleaf <[email protected]> | 2023-10-16 18:52:28 -0700 |
---|---|---|
committer | Spottedleaf <[email protected]> | 2023-10-16 18:52:28 -0700 |
commit | 00331d943e012ba5cd22118607c35e720b06fba0 (patch) | |
tree | 6ac6661637541f41ecc2fddc9d3cf1db690ec748 | |
parent | 2f4281e2b44aed235f12369de84c9bb035746844 (diff) | |
download | Paper-00331d943e012ba5cd22118607c35e720b06fba0.tar.gz Paper-00331d943e012ba5cd22118607c35e720b06fba0.zip |
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.
4 files changed, 40 insertions, 8 deletions
diff --git a/patches/server/0016-Starlight.patch b/patches/server/0016-Starlight.patch index e8d20ddb40..9af642c40d 100644 --- a/patches/server/0016-Starlight.patch +++ b/patches/server/0016-Starlight.patch @@ -4850,6 +4850,38 @@ index 0d536d72ac918fbd403397ff369d10143ee9c204..6051e5f272838ef23276a90e21c2fc82 public static <T> TicketType<T> create(String name, Comparator<T> 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 e96a0ca47e4701ba187555bd92c968345bc85677..33091331ec742767611fad1ab2a324fa334650c5 100644 +--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java ++++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java +@@ -107,6 +107,27 @@ 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 2b8e88a75e9a974e1ecafe0360a9d69b79326d11..6c171199dcc30f56a6d0ab7ecf398b505d145067 100644 --- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java diff --git a/patches/server/0018-Rewrite-chunk-system.patch b/patches/server/0018-Rewrite-chunk-system.patch index 9f6e0db782..d7a0aae9c5 100644 --- a/patches/server/0018-Rewrite-chunk-system.patch +++ b/patches/server/0018-Rewrite-chunk-system.patch @@ -20403,10 +20403,10 @@ index 6051e5f272838ef23276a90e21c2fc821ca155d1..658e63ebde81dc14c8ab5850fb246dc0 public static <T> TicketType<T> create(String name, Comparator<T> 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 e96a0ca47e4701ba187555bd92c968345bc85677..73b96f804079288e9c5fcc11da54e61e89a6782a 100644 +index 33091331ec742767611fad1ab2a324fa334650c5..a38e279c9b36e539c45f410da827056a80acc43c 100644 --- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java +++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java -@@ -504,4 +504,21 @@ public class WorldGenRegion implements WorldGenLevel { +@@ -525,4 +525,21 @@ public class WorldGenRegion implements WorldGenLevel { public long nextSubTickCount() { return this.subTickCount.getAndIncrement(); } @@ -21314,7 +21314,7 @@ index 846ae3fd184a1d63b743aa25e045604576697c96..a907b79fd8291a0e92db138f37239d17 public int getIndex() { diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -index bcdaa86cfd31c2ce4aadad900c348aee0a9e3fc8..85b38592c87bbc071d3fc5de5db131c6626fe004 100644 +index f225a51d284a64d5a962256ab5d7b2d07544dc88..998ca8d123e8b373f0ce5c10f76ec128d35b260a 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java @@ -83,6 +83,7 @@ public class LevelChunk extends ChunkAccess { diff --git a/patches/server/0786-Buffer-OOB-setBlock-calls.patch b/patches/server/0786-Buffer-OOB-setBlock-calls.patch index 4e1905eb3b..d17173fb30 100644 --- a/patches/server/0786-Buffer-OOB-setBlock-calls.patch +++ b/patches/server/0786-Buffer-OOB-setBlock-calls.patch @@ -13,10 +13,10 @@ we'll also only gen a trace for the first one, I see no real pressing need to generate more, given that that would *massively* negate this patch otherwise diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java -index 73b96f804079288e9c5fcc11da54e61e89a6782a..52fd12c474c01f3b53d0f6596b7a6fafee52bd0d 100644 +index a38e279c9b36e539c45f410da827056a80acc43c..78284a89900e6b3ee0c066d00ba3ddf043b63401 100644 --- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java +++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java -@@ -275,6 +275,7 @@ public class WorldGenRegion implements WorldGenLevel { +@@ -296,6 +296,7 @@ public class WorldGenRegion implements WorldGenLevel { } } @@ -24,7 +24,7 @@ index 73b96f804079288e9c5fcc11da54e61e89a6782a..52fd12c474c01f3b53d0f6596b7a6faf @Override public boolean ensureCanWrite(BlockPos pos) { int i = SectionPos.blockToSectionCoord(pos.getX()); -@@ -294,7 +295,15 @@ public class WorldGenRegion implements WorldGenLevel { +@@ -315,7 +316,15 @@ public class WorldGenRegion implements WorldGenLevel { return true; } else { diff --git a/patches/server/0886-Fix-async-entity-add-due-to-fungus-trees.patch b/patches/server/0886-Fix-async-entity-add-due-to-fungus-trees.patch index b1c3709097..a2b4a2f003 100644 --- a/patches/server/0886-Fix-async-entity-add-due-to-fungus-trees.patch +++ b/patches/server/0886-Fix-async-entity-add-due-to-fungus-trees.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix async entity add due to fungus trees diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java -index 52fd12c474c01f3b53d0f6596b7a6fafee52bd0d..877498729c66de9aa6a27c9148f7494d7895615c 100644 +index 78284a89900e6b3ee0c066d00ba3ddf043b63401..50ed7cfe1ecef6d075ba484804827cec83ba2bf2 100644 --- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java +++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java -@@ -228,6 +228,7 @@ public class WorldGenRegion implements WorldGenLevel { +@@ -249,6 +249,7 @@ public class WorldGenRegion implements WorldGenLevel { if (iblockdata.isAir()) { return false; } else { |