aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0689-Optimise-BlockSoil-nearby-water-lookup.patch
diff options
context:
space:
mode:
authorbooky10 <[email protected]>2023-11-04 20:20:01 +0100
committerGitHub <[email protected]>2023-11-04 20:20:01 +0100
commitf78d7ce8ffb7e4b6fd5ee256f5e3678ea04fd807 (patch)
tree8e7abee5129e15a919630824c4f194a2811f7242 /patches/server/0689-Optimise-BlockSoil-nearby-water-lookup.patch
parent44057da46727138e19d951b56e98ad8c25c1f869 (diff)
downloadPaper-f78d7ce8ffb7e4b6fd5ee256f5e3678ea04fd807.tar.gz
Paper-f78d7ce8ffb7e4b6fd5ee256f5e3678ea04fd807.zip
Remove "fix-curing-zombie-villager-discount" exploit option (#9895)
Diffstat (limited to 'patches/server/0689-Optimise-BlockSoil-nearby-water-lookup.patch')
-rw-r--r--patches/server/0689-Optimise-BlockSoil-nearby-water-lookup.patch51
1 files changed, 51 insertions, 0 deletions
diff --git a/patches/server/0689-Optimise-BlockSoil-nearby-water-lookup.patch b/patches/server/0689-Optimise-BlockSoil-nearby-water-lookup.patch
new file mode 100644
index 0000000000..08ef0f3bc8
--- /dev/null
+++ b/patches/server/0689-Optimise-BlockSoil-nearby-water-lookup.patch
@@ -0,0 +1,51 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Spottedleaf <[email protected]>
+Date: Thu, 10 Jun 2021 14:36:00 -0700
+Subject: [PATCH] Optimise BlockSoil nearby water lookup
+
+Apparently the abstract block iteration was taking about
+75% of the method call.
+
+diff --git a/src/main/java/net/minecraft/world/level/block/FarmBlock.java b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
+index 3b4d8a47e7fe08284b79fab2d147629e902db026..5946f06f63b5694034bd027984a4925b0831d439 100644
+--- a/src/main/java/net/minecraft/world/level/block/FarmBlock.java
++++ b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
+@@ -142,19 +142,27 @@ public class FarmBlock extends Block {
+ }
+
+ private static boolean isNearWater(LevelReader world, BlockPos pos) {
+- Iterator iterator = BlockPos.betweenClosed(pos.offset(-4, 0, -4), pos.offset(4, 1, 4)).iterator();
+-
+- BlockPos blockposition1;
+-
+- do {
+- if (!iterator.hasNext()) {
+- return false;
++ // Paper start - remove abstract block iteration
++ int xOff = pos.getX();
++ int yOff = pos.getY();
++ int zOff = pos.getZ();
++
++ for (int dz = -4; dz <= 4; ++dz) {
++ int z = dz + zOff;
++ for (int dx = -4; dx <= 4; ++dx) {
++ int x = xOff + dx;
++ for (int dy = 0; dy <= 1; ++dy) {
++ int y = dy + yOff;
++ net.minecraft.world.level.chunk.LevelChunk chunk = (net.minecraft.world.level.chunk.LevelChunk)world.getChunk(x >> 4, z >> 4);
++ net.minecraft.world.level.material.FluidState fluid = chunk.getBlockStateFinal(x, y, z).getFluidState();
++ if (fluid.is(FluidTags.WATER)) {
++ return true;
++ }
++ }
+ }
++ }
+
+- blockposition1 = (BlockPos) iterator.next();
+- } while (!world.getFluidState(blockposition1).is(FluidTags.WATER));
+-
+- return true;
++ return false;
+ }
+
+ @Override