From 08d8a8538c609472818fa601ee8ec964d2ddb88b Mon Sep 17 00:00:00 2001 From: violetc <58360096+s-yh-china@users.noreply.github.com> Date: Thu, 27 Jun 2024 20:25:34 +0800 Subject: [PATCH] Remove patch by https://github.com/CaffeineMC/lithium-fabric/commit/b7cfd53a1ed0197e1d13dea2799b898eb52ecab3 --- ...006-Leaves-Server-Config-And-Command.patch | 8 +- ...ld-generation-chunk-and-block-access.patch | 88 ------------------- 2 files changed, 4 insertions(+), 92 deletions(-) delete mode 100644 patches/unapplied/server/0077-Optimize-world-generation-chunk-and-block-access.patch diff --git a/patches/server/0006-Leaves-Server-Config-And-Command.patch b/patches/server/0006-Leaves-Server-Config-And-Command.patch index 134a7318..595c8c78 100644 --- a/patches/server/0006-Leaves-Server-Config-And-Command.patch +++ b/patches/server/0006-Leaves-Server-Config-And-Command.patch @@ -85,7 +85,7 @@ index 459f47244bdfeab63b5f16d780b0291d36310de8..a872421bc3e67fdcc929f104f4b085fb .withRequiredArg() diff --git a/src/main/java/org/leavesmc/leaves/LeavesConfig.java b/src/main/java/org/leavesmc/leaves/LeavesConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..b23b13147caef8c8cbc65457afc085e92dda99dc +index 0000000000000000000000000000000000000000..9405d8ff041434a1fce98f744c51b22032889078 --- /dev/null +++ b/src/main/java/org/leavesmc/leaves/LeavesConfig.java @@ -0,0 +1,888 @@ @@ -639,9 +639,6 @@ index 0000000000000000000000000000000000000000..b23b13147caef8c8cbc65457afc085e9 + @GlobalConfig(name = "faster-chunk-serialization", category = "performance") + public static boolean fasterChunkSerialization = true; + -+ @GlobalConfig(name = "optimize-world-generation-and-block-access", category = "performance") -+ public static boolean optimizeWorldGenerationAccess = true; -+ + @GlobalConfig(name = "cache-world-generator-sea-level", category = "performance") + public static boolean cacheWorldGeneratorSeaLevel = true; + @@ -716,6 +713,9 @@ index 0000000000000000000000000000000000000000..b23b13147caef8c8cbc65457afc085e9 + @RemovedConfig(name = "get-nearby-players-streams", category = {"performance", "remove"}) + public static boolean removeGetNearPlayerStreams = true; + ++ @RemovedConfig(name = "optimize-world-generation-and-block-access", category = "performance") ++ public static boolean optimizeWorldGenerationAccess = true; ++ + // Leaves end - performance - removed + + // Leaves end - performance diff --git a/patches/unapplied/server/0077-Optimize-world-generation-chunk-and-block-access.patch b/patches/unapplied/server/0077-Optimize-world-generation-chunk-and-block-access.patch deleted file mode 100644 index a10db99f..00000000 --- a/patches/unapplied/server/0077-Optimize-world-generation-chunk-and-block-access.patch +++ /dev/null @@ -1,88 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Tue, 18 Jul 2023 13:36:25 +0800 -Subject: [PATCH] Optimize world generation chunk and block access - -This patch is Powered by Gale(https://github.com/GaleMC/Gale) - -diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java -index 5a8a33638ceb1d980ffc3e6dd86e7eb11dfd9375..60ac739be2113fe7063af60d50dd23ce2c8b339a 100644 ---- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java -+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java -@@ -84,6 +84,10 @@ public class WorldGenRegion implements WorldGenLevel { - private Supplier currentlyGenerating; - private final AtomicLong subTickCount = new AtomicLong(); - private static final ResourceLocation WORLDGEN_REGION_RANDOM = ResourceLocation.withDefaultNamespace("worldgen_region_random"); -+ // Leaves start - optimize world generation chunk and block access -+ private ChunkAccess[] chunksArr; -+ private int minChunkX, minChunkZ; -+ // Leaves end - optimize world generation chunk and block access - - // Paper start - rewrite chunk system - /** -@@ -125,6 +129,11 @@ public class WorldGenRegion implements WorldGenLevel { - this.random = world.getChunkSource().randomState().getOrCreateRandomFactory(WorldGenRegion.WORLDGEN_REGION_RANDOM).at(this.center.getPos().getWorldPosition()); - this.dimensionType = world.dimensionType(); - this.biomeManager = new BiomeManager(this, BiomeManager.obfuscateSeed(this.seed)); -+ // Leaves start - optimize world generation chunk and block access -+ this.minChunkX = this.firstPos.x; -+ this.minChunkZ = this.firstPos.z; -+ this.chunksArr = chunks.toArray(new ChunkAccess[0]); -+ // Leaves end - optimize world generation chunk and block access - } - - public boolean isOldChunkAround(ChunkPos chunkPos, int checkRadius) { -@@ -142,8 +151,29 @@ public class WorldGenRegion implements WorldGenLevel { - - @Override - public ChunkAccess getChunk(int chunkX, int chunkZ) { -- return this.getChunk(chunkX, chunkZ, ChunkStatus.EMPTY); -+ // Leaves start - optimize world generation chunk and block access -+ if (!org.leavesmc.leaves.LeavesConfig.optimizeWorldGenerationAccess) { -+ return this.getChunk(chunkX, chunkZ, ChunkStatus.EMPTY); -+ } else { -+ int x = chunkX - this.minChunkX; -+ int z = chunkZ - this.minChunkZ; -+ int w = this.size; -+ -+ if (x >= 0 && z >= 0 && x < w && z < w) { -+ return this.chunksArr[x + z * w]; -+ } else { -+ throw new NullPointerException("No chunk exists at " + new ChunkPos(chunkX, chunkZ)); -+ } -+ } -+ // Leaves end - optimize world generation chunk and block access -+ } -+ -+ // Leaves start - optimize world generation chunk and block access -+ public ChunkAccess getChunk(BlockPos pos) { -+ // Skip checking chunk.getStatus().isAtLeast(ChunkStatus.EMPTY) here, because it is always true -+ return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())); - } -+ // Leaves end - optimize world generation chunk and block access - - @Nullable - @Override -@@ -221,7 +251,21 @@ public class WorldGenRegion implements WorldGenLevel { - - @Override - public BlockState getBlockState(BlockPos pos) { -- return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos); -+ // Leaves start - optimize world generation chunk and block access -+ if (!org.leavesmc.leaves.LeavesConfig.optimizeWorldGenerationAccess) { -+ return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos); -+ } else { -+ int x = SectionPos.blockToSectionCoord(pos.getX()) - this.minChunkX; -+ int z = SectionPos.blockToSectionCoord(pos.getZ()) - this.minChunkZ; -+ int w = this.size; -+ -+ if (x >= 0 && z >= 0 && x < w && z < w) { -+ return this.chunksArr[x + z * w].getBlockState(pos); -+ } else { -+ throw new NullPointerException("No chunk exists at " + new ChunkPos(pos)); -+ } -+ } -+ // Leaves end - optimize world generation chunk and block access - } - - @Override