Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
29a0209575
Readds a lost update to the shared mutable state in the random block ticking optimisation.
49 Zeilen
2.6 KiB
Diff
49 Zeilen
2.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Warrior <50800980+Warriorrrr@users.noreply.github.com>
|
|
Date: Sun, 24 Sep 2023 18:35:28 +0200
|
|
Subject: [PATCH] Fix missing map initialize event call
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index 2f2ca1c6d0b329521c4545015a878418870216f0..17610196db7a1c6feb2cf74a02479a8691aa323f 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -2100,7 +2100,23 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
@Nullable
|
|
@Override
|
|
public MapItemSavedData getMapData(String id) {
|
|
- return (MapItemSavedData) this.getServer().overworld().getDataStorage().get(MapItemSavedData.factory(), id);
|
|
+ // Paper start - Call missing map initialize event & set id
|
|
+ final DimensionDataStorage storage = this.getServer().overworld().getDataStorage();
|
|
+
|
|
+ final net.minecraft.world.level.saveddata.SavedData existing = storage.cache.get(id);
|
|
+ if (existing == null && !storage.cache.containsKey(id)) {
|
|
+ final net.minecraft.world.level.saveddata.SavedData.Factory<MapItemSavedData> factory = MapItemSavedData.factory();
|
|
+ final MapItemSavedData map = storage.readSavedData(factory.deserializer(), factory.type(), id);
|
|
+ storage.cache.put(id, map);
|
|
+ if (map != null) {
|
|
+ map.id = id;
|
|
+ new MapInitializeEvent(map.mapView).callEvent();
|
|
+ return map;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return existing instanceof MapItemSavedData data ? data : null;
|
|
+ // Paper end
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java
|
|
index bd30ebc66484a6c4770cf697a2e9b0a123681b1c..f921f55e815a4da01828e025881a7a03591c3978 100644
|
|
--- a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java
|
|
+++ b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java
|
|
@@ -57,7 +57,7 @@ public class DimensionDataStorage {
|
|
}
|
|
|
|
@Nullable
|
|
- private <T extends SavedData> T readSavedData(Function<CompoundTag, T> readFunction, DataFixTypes dataFixTypes, String id) {
|
|
+ public <T extends SavedData> T readSavedData(Function<CompoundTag, T> readFunction, DataFixTypes dataFixTypes, String id) { // Paper
|
|
try {
|
|
File file = this.getDataFile(id);
|
|
if (file.exists()) {
|