mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 04:55:47 +01:00
36f34f01c0
Upstream has released updates that appears 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: da9ef3c5 #496: Add methods to get/set ItemStacks in EquipmentSlots 3abebc9f #492: Let Tameable extend Animals rather than Entity 941111a0 #495: Expose ItemStack and hand used in PlayerShearEntityEvent 4fe19cae #494: InventoryView - Add missing Brewing FUEL_TIME CraftBukkit Changes:933e9094
#664: Add methods to get/set ItemStacks in EquipmentSlots18722312
#662: Expose ItemStack and hand used in PlayerShearEntityEvent
55 lines
3.8 KiB
Diff
55 lines
3.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
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/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
|
index 34cd09a503bfe617bd50808927bae0ccf43e53fc..fa893b14bcef9bab6891dea2c4375b09d74ac038 100644
|
|
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
|
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
|
@@ -23,6 +23,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 {
|
|
|
|
@@ -48,8 +55,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/server/IChunkLoader.java b/src/main/java/net/minecraft/server/IChunkLoader.java
|
|
index 134c76065bf382912e6c28d15449db3f9827f848..25c8b131fec6d9076120bd8ef516b14956a668ec 100644
|
|
--- a/src/main/java/net/minecraft/server/IChunkLoader.java
|
|
+++ b/src/main/java/net/minecraft/server/IChunkLoader.java
|
|
@@ -106,6 +106,13 @@ public class IChunkLoader extends RegionFileCache 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
|
|
super.write(chunkcoordintpair, nbttagcompound);
|
|
if (this.c != null) {
|
|
synchronized (this.persistentDataLock) { // Paper - Async chunk loading
|