diff options
author | Kyle Wood <[email protected]> | 2021-04-24 17:01:33 -0500 |
---|---|---|
committer | Kyle Wood <[email protected]> | 2021-04-25 18:37:43 -0500 |
commit | 3093b81fee3064603c368ab934eddf66ce304433 (patch) | |
tree | cb99f05b5f31de92c41af4cc40b4bef5f3cbf573 /Spigot-Server-Patches-Unmapped/0394-Guard-against-serializing-mismatching-chunk-coordina.patch | |
parent | 1af696a05d21cbdd7b5a7170f95598c013257588 (diff) | |
download | Paper-3093b81fee3064603c368ab934eddf66ce304433.tar.gz Paper-3093b81fee3064603c368ab934eddf66ce304433.zip |
Move patches
Diffstat (limited to 'Spigot-Server-Patches-Unmapped/0394-Guard-against-serializing-mismatching-chunk-coordina.patch')
-rw-r--r-- | Spigot-Server-Patches-Unmapped/0394-Guard-against-serializing-mismatching-chunk-coordina.patch | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/Spigot-Server-Patches-Unmapped/0394-Guard-against-serializing-mismatching-chunk-coordina.patch b/Spigot-Server-Patches-Unmapped/0394-Guard-against-serializing-mismatching-chunk-coordina.patch new file mode 100644 index 0000000000..1c55da068c --- /dev/null +++ b/Spigot-Server-Patches-Unmapped/0394-Guard-against-serializing-mismatching-chunk-coordina.patch @@ -0,0 +1,62 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Spottedleaf <[email protected]> +Date: Fri, 27 Dec 2019 09:42:26 -0800 +Subject: [PATCH] Guard against serializing mismatching chunk coordinate + +Should help if something dumb happens + +diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java +index c95fcdf47db8bfe59a83c0d28f4744b4d8540ef8..e16e046d165330326ed220c9c440a637007f3137 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java ++++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java +@@ -67,6 +67,13 @@ public class ChunkRegionLoader { + + private static final Logger LOGGER = LogManager.getLogger(); + ++ // Paper start - guard against serializing mismatching coordinates ++ // TODO Note: This needs to be re-checked each update ++ public static ChunkCoordIntPair getChunkCoordinate(NBTTagCompound chunkData) { ++ NBTTagCompound levelData = chunkData.getCompound("Level"); ++ return new ChunkCoordIntPair(levelData.getInt("xPos"), levelData.getInt("zPos")); ++ } ++ // Paper end + // Paper start + public static final class InProgressChunkHolder { + +@@ -92,8 +99,8 @@ public class ChunkRegionLoader { + // Paper end + ChunkGenerator chunkgenerator = worldserver.getChunkProvider().getChunkGenerator(); + WorldChunkManager worldchunkmanager = chunkgenerator.getWorldChunkManager(); +- NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Level"); +- ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos")); ++ NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Level"); // Paper - diff on change, see ChunkRegionLoader#getChunkCoordinate ++ ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos")); // Paper - diff on change, see ChunkRegionLoader#getChunkCoordinate + + if (!Objects.equals(chunkcoordintpair, chunkcoordintpair1)) { + ChunkRegionLoader.LOGGER.error("Chunk file at {} is in the wrong location; relocating. (Expected {}, got {})", chunkcoordintpair, chunkcoordintpair, chunkcoordintpair1); +diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/IChunkLoader.java b/src/main/java/net/minecraft/world/level/chunk/storage/IChunkLoader.java +index 01ae13385dd0208c9f34da8b3897b571f86305d0..890362d28ab9cb760c73fe5014e144fb08ada6b8 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/storage/IChunkLoader.java ++++ b/src/main/java/net/minecraft/world/level/chunk/storage/IChunkLoader.java +@@ -13,6 +13,7 @@ import net.minecraft.SharedConstants; + import net.minecraft.nbt.GameProfileSerializer; + import net.minecraft.nbt.NBTTagCompound; + import net.minecraft.resources.ResourceKey; ++import net.minecraft.server.level.PlayerChunkMap; + import net.minecraft.util.datafix.DataFixTypes; + import net.minecraft.world.level.ChunkCoordIntPair; + import net.minecraft.world.level.World; +@@ -123,6 +124,13 @@ public class IChunkLoader implements AutoCloseable { + + public void a(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException { write(chunkcoordintpair, nbttagcompound); } // Paper OBFHELPER + public void write(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException { // Paper - OBFHELPER - (Switched around for safety) ++ // Paper start ++ if (!chunkcoordintpair.equals(ChunkRegionLoader.getChunkCoordinate(nbttagcompound))) { ++ String world = (this instanceof PlayerChunkMap) ? ((PlayerChunkMap)this).world.getWorld().getName() : null; ++ throw new IllegalArgumentException("Chunk coordinate and serialized data do not have matching coordinates, trying to serialize coordinate " + chunkcoordintpair.toString() ++ + " but compound says coordinate is " + ChunkRegionLoader.getChunkCoordinate(nbttagcompound).toString() + (world == null ? " for an unknown world" : (" for world: " + world))); ++ } ++ // Paper end + this.regionFileCache.write(chunkcoordintpair, nbttagcompound); + if (this.c != null) { + synchronized (this.persistentDataLock) { // Paper - Async chunk loading |