aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0118-Bound-Treasure-Maps-to-World-Border.patch
blob: ff7bd30c615f2a7e457c954f0b6ab8d5f22bb7d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
index a0c4bc4eb42a3d2de6f66510d88f92c06b535353..c2c54dc4bbfe469f2b8c751012b93d5e728936d6 100644
--- a/src/main/java/net/minecraft/world/level/border/WorldBorder.java
+++ b/src/main/java/net/minecraft/world/level/border/WorldBorder.java
@@ -36,6 +36,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
+    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
+
     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/levelgen/feature/StructureFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/StructureFeature.java
index 9aaa5faff7cdabd54189598b0938fdc6354e2bb8..d7129f3379f2edecbcfd85f83d75e4d7064ce71d 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/StructureFeature.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/StructureFeature.java
@@ -168,6 +168,7 @@ public abstract class StructureFeature<C extends FeatureConfiguration> {
                         int o = j + i * m;
                         int p = k + i * n;
                         ChunkPos chunkPos = this.getPotentialFeatureChunk(config, worldSeed, worldgenRandom, o, p);
+                        if (!world.getWorldBorder().isChunkInBounds(chunkPos.x, chunkPos.z)) { continue; } // Paper
                         boolean bl3 = world.getBiomeManager().getPrimaryBiomeAtChunk(chunkPos).getGenerationSettings().isValidStart(this);
                         if (bl3) {
                             ChunkAccess chunkAccess = world.getChunk(chunkPos.x, chunkPos.z, ChunkStatus.STRUCTURE_STARTS);