3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-22 14:28:09 +01:00
Paper/Spigot-Server-Patches/0160-Bound-Treasure-Maps-to-World-Border.patch

51 Zeilen
2.7 KiB
Diff

2018-07-17 22:32:05 +02:00
From 6a37edaf0197147075c033b77c864f8d3de94a07 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/server/StructureGenerator.java b/src/main/java/net/minecraft/server/StructureGenerator.java
2018-07-17 22:32:05 +02:00
index 263ea953a..8b8b468f3 100644
--- a/src/main/java/net/minecraft/server/StructureGenerator.java
+++ b/src/main/java/net/minecraft/server/StructureGenerator.java
2018-07-17 22:32:05 +02:00
@@ -124,6 +124,7 @@ public abstract class StructureGenerator<C extends WorldGenFeatureConfiguration>
2018-07-17 22:32:05 +02:00
if (flag || flag1) {
ChunkCoordIntPair chunkcoordintpair = this.a(chunkgenerator, seededrandom, j, k, i1, j1);
+ if (!world.getWorldBorder().isChunkInBounds(chunkcoordintpair.x, chunkcoordintpair.z)) { continue; } // Paper
StructureStart structurestart = this.a(world, chunkgenerator, seededrandom, chunkcoordintpair.a());
if (structurestart != StructureGenerator.a) {
diff --git a/src/main/java/net/minecraft/server/WorldBorder.java b/src/main/java/net/minecraft/server/WorldBorder.java
2018-07-17 22:32:05 +02:00
index ec5386fd5..08424a88b 100644
--- a/src/main/java/net/minecraft/server/WorldBorder.java
+++ b/src/main/java/net/minecraft/server/WorldBorder.java
@@ -33,6 +33,18 @@ public class WorldBorder {
return (double) (blockposition.getX() + 1) > this.b() && (double) blockposition.getX() < this.d() && (double) (blockposition.getZ() + 1) > this.c() && (double) blockposition.getZ() < this.e();
}
+ // Paper start
+ private final BlockPosition.MutableBlockPosition mutPos = new BlockPosition.MutableBlockPosition();
+ public boolean isBlockInBounds(int chunkX, int chunkZ) {
+ mutPos.setValues(chunkX, 64, chunkZ);
+ return isInBounds(mutPos);
+ }
+ public boolean isChunkInBounds(int chunkX, int chunkZ) {
+ mutPos.setValues(((chunkX << 4) + 15), 64, (chunkZ << 4) + 15);
+ return isInBounds(mutPos);
+ }
+ // Paper end
+
public boolean isInBounds(ChunkCoordIntPair chunkcoordintpair) {
2018-07-17 22:32:05 +02:00
return (double) chunkcoordintpair.f() > this.b() && (double) chunkcoordintpair.d() < this.d() && (double) chunkcoordintpair.g() > this.c() && (double) chunkcoordintpair.e() < this.e();
}
--
2.18.0