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

48 lines
3 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
2021-11-23 14:22:49 +01:00
index 6ec5a1525d0b8ced8fe78d3eab29c5eb82996844..2442c287a7f26cfee10a19e9015558cdebdcf3ac 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
2021-11-23 14:22:49 +01:00
@@ -37,6 +37,18 @@ public class WorldBorder {
2021-06-11 14:02:28 +02:00
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) {
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
+
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
2021-11-23 14:22:49 +01:00
index 3ff9f40df7f4f837a59362c6da6a172f42d6e8bc..0670c1f72d9d0c4f8ea32ed314f75a106b2e2b09 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/StructureFeature.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/StructureFeature.java
2021-11-23 14:22:49 +01:00
@@ -168,6 +168,7 @@ public class StructureFeature<C extends FeatureConfiguration> {
int o = j + i * m;
int p = k + i * n;
2021-11-23 14:22:49 +01:00
ChunkPos chunkPos = this.getPotentialFeatureChunk(config, worldSeed, o, p);
+ if (!levelReader.getWorldBorder().isChunkInBounds(chunkPos.x, chunkPos.z)) { continue; } // Paper
StructureCheckResult structureCheckResult = structureAccessor.checkStructurePresence(chunkPos, this, skipExistingChunks);
if (structureCheckResult != StructureCheckResult.START_NOT_PRESENT) {
if (!skipExistingChunks && structureCheckResult == StructureCheckResult.START_PRESENT) {