PaperMC/patches/server/0116-Bound-Treasure-Maps-to-World-Border.patch

48 lines
2.9 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 20 Dec 2016 15:15:11 -0500
Subject: [PATCH] Bound Treasure Maps to World Border
Make it so a Treasure Map does not target a structure outside of the
World Border, where players are not even able to reach.
This also would help the case where a players close to the border, and one
that is outside happens to be closer, but unreachable, yet another reachable
one is in border that would of been missed.
diff --git a/src/main/java/net/minecraft/world/level/border/WorldBorder.java b/src/main/java/net/minecraft/world/level/border/WorldBorder.java
2024-06-13 19:30:39 +02:00
index a3ba3a09378e3bd0517464130ad2c702b0b0165d..3442e33a1146318228c4727a2a5afde685f69bf7 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/border/WorldBorder.java
+++ b/src/main/java/net/minecraft/world/level/border/WorldBorder.java
2024-06-13 19:30:39 +02:00
@@ -46,6 +46,18 @@ public class WorldBorder {
return this.isWithinBounds((double) chunkPos.getMinBlockX(), (double) chunkPos.getMinBlockZ()) && this.isWithinBounds((double) chunkPos.getMaxBlockX(), (double) chunkPos.getMaxBlockZ());
2021-06-11 14:02:28 +02:00
}
+ // Paper start - Bound treasure maps to world border
2021-06-11 14:02:28 +02:00
+ private final BlockPos.MutableBlockPos mutPos = new BlockPos.MutableBlockPos();
+ public boolean isBlockInBounds(int chunkX, int chunkZ) {
2021-06-17 23:39:36 +02:00
+ this.mutPos.set(chunkX, 64, chunkZ);
+ return this.isWithinBounds(this.mutPos);
2021-06-11 14:02:28 +02:00
+ }
+ public boolean isChunkInBounds(int chunkX, int chunkZ) {
2021-06-17 23:39:36 +02:00
+ this.mutPos.set(((chunkX << 4) + 15), 64, (chunkZ << 4) + 15);
+ return this.isWithinBounds(this.mutPos);
2021-06-11 14:02:28 +02:00
+ }
+ // Paper end - Bound treasure maps to world border
2021-06-11 14:02:28 +02:00
+
2024-06-13 19:30:39 +02:00
public boolean isWithinBounds(AABB box) {
return this.isWithinBounds(box.minX, box.minZ, box.maxX - 9.999999747378752E-6D, box.maxZ - 9.999999747378752E-6D);
2021-06-11 14:02:28 +02:00
}
2022-03-01 06:43:03 +01:00
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
2024-06-13 19:30:39 +02:00
index a53fa9bebdd46939a710e46466ca9a350ecefb27..0a779632c9d11496fcfc147870fba2699d9cc274 100644
2022-03-01 06:43:03 +01:00
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
2024-06-13 19:30:39 +02:00
@@ -222,6 +222,7 @@ public abstract class ChunkGenerator {
2022-03-01 06:43:03 +01:00
2022-06-07 21:55:39 +02:00
while (iterator.hasNext()) {
ChunkPos chunkcoordintpair = (ChunkPos) iterator.next();
+ if (!world.paperConfig().environment.locateStructuresOutsideWorldBorder && !world.getWorldBorder().isChunkInBounds(chunkcoordintpair.x, chunkcoordintpair.z)) { continue; } // Paper - Bound treasure maps to world border
2022-06-07 21:55:39 +02:00
blockposition_mutableblockposition.set(SectionPos.sectionToBlockCoord(chunkcoordintpair.x, 8), 32, SectionPos.sectionToBlockCoord(chunkcoordintpair.z, 8));
double d1 = blockposition_mutableblockposition.distSqr(center);