diff options
author | Owen <[email protected]> | 2024-03-03 17:05:34 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2024-03-03 17:05:34 -0500 |
commit | 89d51d5f298cd25d6f44388970596c6780b5664b (patch) | |
tree | 07f41f4ce7bc466ea5e35faa2575d0ec6f6c4a76 /patches/server/0926-Optimize-nearest-structure-border-iteration.patch | |
parent | b21eb4d9a4d0d0bea857675e2186657592df548e (diff) | |
download | Paper-89d51d5f298cd25d6f44388970596c6780b5664b.tar.gz Paper-89d51d5f298cd25d6f44388970596c6780b5664b.zip |
Allow enabling sand duping (#10191)
Because this exploit has been widely known for years and has not been fixed by Mojang, we decided that it was worth allowing people to toggle it on/off due to how easy it is to make it configurable.
It should be noted that this decision does not promise all future exploits will be configurable.
Diffstat (limited to 'patches/server/0926-Optimize-nearest-structure-border-iteration.patch')
-rw-r--r-- | patches/server/0926-Optimize-nearest-structure-border-iteration.patch | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/patches/server/0926-Optimize-nearest-structure-border-iteration.patch b/patches/server/0926-Optimize-nearest-structure-border-iteration.patch new file mode 100644 index 0000000000..e073d7a1df --- /dev/null +++ b/patches/server/0926-Optimize-nearest-structure-border-iteration.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers <[email protected]> +Date: Mon, 21 Aug 2023 21:05:09 +0200 +Subject: [PATCH] Optimize nearest structure border iteration + +Getting the nearest generated structure contains a nested set of loops that +iterates over all chunks at a specific chessboard distance. It does this by +iterating over the entire square of chunks within that distance, and checking +if the coordinates are at exactly the right distance to be on the border. + +This patch optimizes the iteration by only iterating over the border chunks. +This evaluated chunks are the same, and in the same order, as before, to +ensure that the returned found structure (which may for example be a buried +treasure that will be marked on a treasure map) is the same as in vanilla. + +diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java +index f767c822a8e86ce689d40d12c4ef2db3829a97cc..b26a4eb4951e87f891b59028d98b8ffba8e103a8 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java ++++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java +@@ -260,12 +260,15 @@ public abstract class ChunkGenerator { + int i1 = placement.spacing(); + + for (int j1 = -radius; j1 <= radius; ++j1) { +- boolean flag1 = j1 == -radius || j1 == radius; ++ // Paper start - Perf: iterate over border chunks instead of entire square chunk area ++ boolean flag1 = j1 == -radius || j1 == radius; final boolean onBorderAlongZAxis = flag1; // Paper - OBFHELPER + +- for (int k1 = -radius; k1 <= radius; ++k1) { +- boolean flag2 = k1 == -radius || k1 == radius; ++ for (int k1 = -radius; k1 <= radius; k1 += onBorderAlongZAxis ? 1 : radius * 2) { ++ // boolean flag2 = k1 == -radius || k1 == radius; + +- if (flag1 || flag2) { ++ // if (flag1 || flag2) { ++ if (true) { ++ // Paper end - Perf: iterate over border chunks instead of entire square chunk area + int l1 = centerChunkX + i1 * j1; + int i2 = centerChunkZ + i1 * k1; + ChunkPos chunkcoordintpair = placement.getPotentialStructureChunk(seed, l1, i2); |