aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0121-Bound-Treasure-Maps-to-World-Border.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0121-Bound-Treasure-Maps-to-World-Border.patch')
-rw-r--r--patches/server/0121-Bound-Treasure-Maps-to-World-Border.patch47
1 files changed, 47 insertions, 0 deletions
diff --git a/patches/server/0121-Bound-Treasure-Maps-to-World-Border.patch b/patches/server/0121-Bound-Treasure-Maps-to-World-Border.patch
new file mode 100644
index 0000000000..507479d986
--- /dev/null
+++ b/patches/server/0121-Bound-Treasure-Maps-to-World-Border.patch
@@ -0,0 +1,47 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Aikar <[email protected]>
+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
+index c34873ec974eeffbc4f66dab4584c696cbe10967..580eb275942570da9e68287ca75da886ba1248c0 100644
+--- a/src/main/java/net/minecraft/world/level/border/WorldBorder.java
++++ b/src/main/java/net/minecraft/world/level/border/WorldBorder.java
+@@ -37,6 +37,18 @@ public class WorldBorder {
+ return (double) (pos.getX() + 1) > this.getMinX() && (double) pos.getX() < this.getMaxX() && (double) (pos.getZ() + 1) > this.getMinZ() && (double) pos.getZ() < this.getMaxZ();
+ }
+
++ // Paper start - Bound treasure maps to world border
++ private final BlockPos.MutableBlockPos mutPos = new BlockPos.MutableBlockPos();
++ public boolean isBlockInBounds(int chunkX, int chunkZ) {
++ this.mutPos.set(chunkX, 64, chunkZ);
++ return this.isWithinBounds(this.mutPos);
++ }
++ public boolean isChunkInBounds(int chunkX, int chunkZ) {
++ this.mutPos.set(((chunkX << 4) + 15), 64, (chunkZ << 4) + 15);
++ return this.isWithinBounds(this.mutPos);
++ }
++ // Paper end - Bound treasure maps to world border
++
+ public boolean isWithinBounds(ChunkPos pos) {
+ return (double) pos.getMaxBlockX() > this.getMinX() && (double) pos.getMinBlockX() < this.getMaxX() && (double) pos.getMaxBlockZ() > this.getMinZ() && (double) pos.getMinBlockZ() < this.getMaxZ();
+ }
+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 28bc3447ff5ddc066a9a743d5bfa7ca69598cd51..7cdb59cd2f2ffe1195d21519ef97dae0e430285b 100644
+--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
++++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
+@@ -223,6 +223,7 @@ public abstract class ChunkGenerator {
+
+ 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
+
+ blockposition_mutableblockposition.set(SectionPos.sectionToBlockCoord(chunkcoordintpair.x, 8), 32, SectionPos.sectionToBlockCoord(chunkcoordintpair.z, 8));
+ double d1 = blockposition_mutableblockposition.distSqr(center);