mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
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.
This commit is contained in:
parent
ddd1807ad5
commit
63de7b1ff6
2 changed files with 37 additions and 9 deletions
|
@ -8,7 +8,27 @@
|
||||||
|
|
||||||
public WorldBorder() {}
|
public WorldBorder() {}
|
||||||
|
|
||||||
@@ -189,6 +190,7 @@
|
@@ -43,7 +44,19 @@
|
||||||
|
|
||||||
|
public boolean isWithinBounds(ChunkPos chunkPos) {
|
||||||
|
return this.isWithinBounds((double) chunkPos.getMinBlockX(), (double) chunkPos.getMinBlockZ()) && this.isWithinBounds((double) chunkPos.getMaxBlockX(), (double) chunkPos.getMaxBlockZ());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // 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(AABB box) {
|
||||||
|
return this.isWithinBounds(box.minX, box.minZ, box.maxX - 9.999999747378752E-6D, box.maxZ - 9.999999747378752E-6D);
|
||||||
|
@@ -189,6 +202,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListener(BorderChangeListener listener) {
|
public void addListener(BorderChangeListener listener) {
|
||||||
|
|
|
@ -11,7 +11,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ResourceKey<MapCodec<? extends ChunkGenerator>>> getTypeNameForDataFixer() {
|
public Optional<ResourceKey<MapCodec<? extends ChunkGenerator>>> getTypeNameForDataFixer() {
|
||||||
@@ -312,29 +312,29 @@
|
@@ -223,6 +223,7 @@
|
||||||
|
|
||||||
|
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);
|
||||||
|
@@ -312,29 +313,29 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +56,7 @@
|
||||||
|
|
||||||
Objects.requireNonNull(set);
|
Objects.requireNonNull(set);
|
||||||
palettedcontainerro.getAll(set::add);
|
palettedcontainerro.getAll(set::add);
|
||||||
@@ -345,7 +345,7 @@
|
@@ -345,7 +346,7 @@
|
||||||
int j = list.size();
|
int j = list.size();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -57,7 +65,7 @@
|
||||||
int k = Math.max(GenerationStep.Decoration.values().length, j);
|
int k = Math.max(GenerationStep.Decoration.values().length, j);
|
||||||
|
|
||||||
for (int l = 0; l < k; ++l) {
|
for (int l = 0; l < k; ++l) {
|
||||||
@@ -353,7 +353,7 @@
|
@@ -353,7 +354,7 @@
|
||||||
Iterator iterator;
|
Iterator iterator;
|
||||||
CrashReportCategory crashreportsystemdetails;
|
CrashReportCategory crashreportsystemdetails;
|
||||||
|
|
||||||
|
@ -66,7 +74,7 @@
|
||||||
List<Structure> list1 = (List) map.getOrDefault(l, Collections.emptyList());
|
List<Structure> list1 = (List) map.getOrDefault(l, Collections.emptyList());
|
||||||
|
|
||||||
for (iterator = list1.iterator(); iterator.hasNext(); ++i1) {
|
for (iterator = list1.iterator(); iterator.hasNext(); ++i1) {
|
||||||
@@ -368,9 +368,9 @@
|
@@ -368,9 +369,9 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -79,7 +87,7 @@
|
||||||
});
|
});
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
CrashReport crashreport = CrashReport.forThrowable(exception, "Feature placement");
|
CrashReport crashreport = CrashReport.forThrowable(exception, "Feature placement");
|
||||||
@@ -421,8 +421,8 @@
|
@@ -421,8 +422,8 @@
|
||||||
seededrandom.setFeatureSeed(i, l1, l);
|
seededrandom.setFeatureSeed(i, l1, l);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -90,7 +98,7 @@
|
||||||
} catch (Exception exception1) {
|
} catch (Exception exception1) {
|
||||||
CrashReport crashreport1 = CrashReport.forThrowable(exception1, "Feature placement");
|
CrashReport crashreport1 = CrashReport.forThrowable(exception1, "Feature placement");
|
||||||
|
|
||||||
@@ -435,7 +435,7 @@
|
@@ -435,7 +436,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +107,7 @@
|
||||||
} catch (Exception exception2) {
|
} catch (Exception exception2) {
|
||||||
CrashReport crashreport2 = CrashReport.forThrowable(exception2, "Biome decoration");
|
CrashReport crashreport2 = CrashReport.forThrowable(exception2, "Biome decoration");
|
||||||
|
|
||||||
@@ -445,6 +445,33 @@
|
@@ -445,6 +446,33 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +141,7 @@
|
||||||
private static BoundingBox getWritableArea(ChunkAccess chunk) {
|
private static BoundingBox getWritableArea(ChunkAccess chunk) {
|
||||||
ChunkPos chunkcoordintpair = chunk.getPos();
|
ChunkPos chunkcoordintpair = chunk.getPos();
|
||||||
int i = chunkcoordintpair.getMinBlockX();
|
int i = chunkcoordintpair.getMinBlockX();
|
||||||
@@ -582,6 +609,14 @@
|
@@ -582,6 +610,14 @@
|
||||||
StructureStart structurestart = structure.generate(weightedEntry.structure(), dimension, dynamicRegistryManager, this, this.biomeSource, noiseConfig, structureManager, seed, pos, j, chunk, predicate);
|
StructureStart structurestart = structure.generate(weightedEntry.structure(), dimension, dynamicRegistryManager, this, this.biomeSource, noiseConfig, structureManager, seed, pos, j, chunk, predicate);
|
||||||
|
|
||||||
if (structurestart.isValid()) {
|
if (structurestart.isValid()) {
|
||||||
|
|
Loading…
Reference in a new issue