Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
ef0e5a642d
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: 9ae3f10f SPIGOT-3842: Add Player#fireworkBoost() and expand Firework API 48c0c547 PR-786: Add methods to get sounds from entities CraftBukkit Changes: 5cc9c022a SPIGOT-7152: Handle hand item changing during air interact event 4ffa1acf6 SPIGOT-7154: Players get kicked when interacting with a conversation 4daa21123 SPIGOT-3842: Add Player#fireworkBoost() and expand Firework API e5d6a9bbf PR-1100: Add methods to get sounds from entities b7e9f1c8b SPIGOT-7146: Reduce use of Material switch in ItemMeta Spigot Changes: 4c157bb4 Rebuild patches
58 Zeilen
3.6 KiB
Diff
58 Zeilen
3.6 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/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
|
index 8480310bd389ad55b8138a20da59cbcffb973819..864e591b10360b0f12fe5c5a650da372555ebd10 100644
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
|
@@ -84,6 +84,18 @@ public class ChunkSerializer {
|
|
|
|
public ChunkSerializer() {}
|
|
|
|
+ // Paper start - guard against serializing mismatching coordinates
|
|
+ // TODO Note: This needs to be re-checked each update
|
|
+ public static ChunkPos getChunkCoordinate(CompoundTag chunkData) {
|
|
+ final int dataVersion = ChunkStorage.getVersion(chunkData);
|
|
+ if (dataVersion < 2842) { // Level tag is removed after this version
|
|
+ final CompoundTag levelData = chunkData.getCompound("Level");
|
|
+ return new ChunkPos(levelData.getInt("xPos"), levelData.getInt("zPos"));
|
|
+ } else {
|
|
+ return new ChunkPos(chunkData.getInt("xPos"), chunkData.getInt("zPos"));
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
// Paper start
|
|
public static final class InProgressChunkHolder {
|
|
|
|
@@ -109,7 +121,7 @@ public class ChunkSerializer {
|
|
public static InProgressChunkHolder loadChunk(ServerLevel world, PoiManager poiStorage, ChunkPos chunkPos, CompoundTag nbt, boolean distinguish) {
|
|
java.util.ArrayDeque<Runnable> tasksToExecuteOnMain = new java.util.ArrayDeque<>();
|
|
// Paper end
|
|
- ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos"));
|
|
+ ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - diff on change, see ChunkSerializer#getChunkCoordinate
|
|
|
|
if (!Objects.equals(chunkPos, chunkcoordintpair1)) {
|
|
ChunkSerializer.LOGGER.error("Chunk file at {} is in the wrong location; relocating. (Expected {}, got {})", new Object[]{chunkPos, chunkPos, chunkcoordintpair1});
|
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
|
index 694778b5c23dbe9c8603c3483476b5252aa079bc..315be30daf0be84efbb4d634dc01e1bf9e6e696e 100644
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
|
@@ -178,6 +178,13 @@ public class ChunkStorage implements AutoCloseable {
|
|
|
|
// Paper start - async chunk io
|
|
public void write(ChunkPos chunkPos, CompoundTag nbt) throws IOException {
|
|
+ // Paper start
|
|
+ if (!chunkPos.equals(ChunkSerializer.getChunkCoordinate(nbt))) {
|
|
+ String world = (this instanceof net.minecraft.server.level.ChunkMap) ? ((net.minecraft.server.level.ChunkMap)this).level.getWorld().getName() : null;
|
|
+ throw new IllegalArgumentException("Chunk coordinate and serialized data do not have matching coordinates, trying to serialize coordinate " + chunkPos.toString()
|
|
+ + " but compound says coordinate is " + ChunkSerializer.getChunkCoordinate(nbt).toString() + (world == null ? " for an unknown world" : (" for world: " + world)));
|
|
+ }
|
|
+ // Paper end
|
|
this.regionFileCache.write(chunkPos, nbt);
|
|
// Paper end - Async chunk loading
|
|
if (this.legacyStructureHandler != null) {
|