mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-06 02:42:14 +01:00
e035fd7034
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: cc9aa21a SPIGOT-6399, SPIGOT-7344: Clarify collidable behavior for player entities f23325b6 Add API for per-world simulation distances 26e1774e Add API for per-world view distances 0b541e60 Add PlayerLoginEvent#getRealAddress 5f027d2d PR-949: Add Vector#fromJOML() overloads for read-only vector types CraftBukkit Changes: bcf56171a PR-1321: Clean up some stuff which got missed during previous PRs 7f833a2d1 SPIGOT-7462: Players no longer drop XP after dying near a Sculk Catalyst 752aac669 Implement APIs for per world view and simulation distances 57d7ef433 Preserve empty enchantment tags for glow effect 465ec3fb4 Remove connected check on setScoreboard f90ce621e Use one PermissibleBase for all command blocks 5876cca44 SPIGOT-7550: Fix creation of Arrow instances f03fc3aa3 SPIGOT-7549: ServerTickManager#setTickRate incorrect Precondition 9d7f49b01 SPIGOT-7548: Fix wrong spawn location for experience orb and dropped item Spigot Changes: ed9ba9a4 Drop no longer required patch ignoring -o option 86b5dd6a SPIGOT-7546: Fix hardcoded check for outdated client message aa7cde7a Remove obsolete APIs for per world view and simulation distances 6dff577e Remove obsolete patch preserving empty `ench` tags a3bf95b8 Remove obsolete PlayerLoginEvent#getRealAddress 1b02f5d6 Remove obsolete connected check on setScoreboard patch acf717eb Remove obsolete command block PermissibleBase patch 053fa2a9 Remove redundant patch dealing with null tile entities
97 lines
5.3 KiB
Diff
97 lines
5.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
|
Date: Fri, 29 Jul 2022 12:35:19 -0400
|
|
Subject: [PATCH] Warn on plugins accessing faraway chunks
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
index 2e96fadbead617096ef6dd96b37f967da9a30395..440e99f24fdbc73fa51d5d3aa8aabfae9fc4deca 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -813,7 +813,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
}
|
|
|
|
private static boolean isInWorldBoundsHorizontal(BlockPos pos) {
|
|
- return pos.getX() >= -30000000 && pos.getZ() >= -30000000 && pos.getX() < 30000000 && pos.getZ() < 30000000;
|
|
+ return pos.getX() >= -30000000 && pos.getZ() >= -30000000 && pos.getX() < 30000000 && pos.getZ() < 30000000; // Dif on change
|
|
}
|
|
|
|
private static boolean isOutsideSpawnableHeight(int y) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
index 56a020427757ad4e91f9bffd1e75fe78bcb4d6af..c96d1956049eecfb395ad75b971c07dcd4c71107 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -312,9 +312,24 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
public boolean setSpawnLocation(int x, int y, int z) {
|
|
return this.setSpawnLocation(x, y, z, 0.0F);
|
|
}
|
|
+ // Paper start
|
|
+ private static void warnUnsafeChunk(String reason, int x, int z) {
|
|
+ // if any chunk coord is outside of 30 million blocks
|
|
+ if (x > 1875000 || z > 1875000 || x < -1875000 || z < -1875000) {
|
|
+ Plugin plugin = io.papermc.paper.util.StackWalkerUtil.getFirstPluginCaller();
|
|
+ if (plugin != null) {
|
|
+ plugin.getLogger().warning("Plugin is %s at (%s, %s), this might cause issues.".formatted(reason, x, z));
|
|
+ }
|
|
+ if (net.minecraft.server.MinecraftServer.getServer().isDebugging()) {
|
|
+ io.papermc.paper.util.TraceUtil.dumpTraceForThread("Dangerous chunk retrieval");
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
|
|
@Override
|
|
public Chunk getChunkAt(int x, int z) {
|
|
+ warnUnsafeChunk("getting a faraway chunk", x, z); // Paper
|
|
// Paper start - add ticket to hold chunk for a little while longer if plugin accesses it
|
|
net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkSource().getChunkAtIfLoadedImmediately(x, z);
|
|
if (chunk == null) {
|
|
@@ -429,6 +444,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
@Override
|
|
public boolean regenerateChunk(int x, int z) {
|
|
org.spigotmc.AsyncCatcher.catchOp("chunk regenerate"); // Spigot
|
|
+ warnUnsafeChunk("regenerating a faraway chunk", x, z); // Paper
|
|
// Paper start - implement regenerateChunk method
|
|
final ServerLevel serverLevel = this.world;
|
|
final net.minecraft.server.level.ServerChunkCache serverChunkCache = serverLevel.getChunkSource();
|
|
@@ -524,6 +540,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
@Override
|
|
public boolean loadChunk(int x, int z, boolean generate) {
|
|
org.spigotmc.AsyncCatcher.catchOp("chunk load"); // Spigot
|
|
+ warnUnsafeChunk("loading a faraway chunk", x, z); // Paper
|
|
// Paper start - Optimize this method
|
|
ChunkPos chunkPos = new ChunkPos(x, z);
|
|
ChunkAccess immediate = world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); // Paper
|
|
@@ -587,6 +604,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
@Override
|
|
public boolean addPluginChunkTicket(int x, int z, Plugin plugin) {
|
|
+ warnUnsafeChunk("adding a faraway chunk ticket", x, z); // Paper
|
|
Preconditions.checkArgument(plugin != null, "null plugin");
|
|
Preconditions.checkArgument(plugin.isEnabled(), "plugin is not enabled");
|
|
|
|
@@ -655,6 +673,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
@Override
|
|
public void setChunkForceLoaded(int x, int z, boolean forced) {
|
|
+ warnUnsafeChunk("forceloading a faraway chunk", x, z); // Paper
|
|
this.getHandle().setChunkForced(x, z, forced);
|
|
}
|
|
|
|
@@ -967,6 +986,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
@Override
|
|
public int getHighestBlockYAt(int x, int z, org.bukkit.HeightMap heightMap) {
|
|
+ warnUnsafeChunk("getting a faraway chunk", x >> 4, z >> 4); // Paper
|
|
// Transient load for this tick
|
|
return this.world.getChunk(x >> 4, z >> 4).getHeight(CraftHeightMap.toNMS(heightMap), x, z);
|
|
}
|
|
@@ -2417,6 +2437,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
// Spigot end
|
|
// Paper start
|
|
public java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen, boolean urgent) {
|
|
+ warnUnsafeChunk("getting a faraway chunk async", x, z); // Paper
|
|
if (Bukkit.isPrimaryThread()) {
|
|
net.minecraft.world.level.chunk.LevelChunk immediate = this.world.getChunkSource().getChunkAtIfLoadedImmediately(x, z);
|
|
if (immediate != null) {
|