mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Fix missing map initialize event call & missing map id assignment (#9756)
This commit is contained in:
parent
358877e2e2
commit
2474c6ac97
1 changed files with 48 additions and 0 deletions
48
patches/server/Fix-missing-map-initialize-event-call.patch
Normal file
48
patches/server/Fix-missing-map-initialize-event-call.patch
Normal file
|
@ -0,0 +1,48 @@
|
|||
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -0,0 +0,0 @@ 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);
|
||||
+ if (map != null) {
|
||||
+ map.id = id;
|
||||
+ new MapInitializeEvent(map.mapView).callEvent();
|
||||
+ }
|
||||
+
|
||||
+ storage.cache.put(id, 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java
|
||||
@@ -0,0 +0,0 @@ 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()) {
|
Loading…
Reference in a new issue