Quick tweaks to logical flow of getMapData

This commit is contained in:
Shane Freeder 2023-10-04 16:25:26 +01:00
parent f36bb59739
commit 5eec4ec3bf
No known key found for this signature in database
GPG key ID: A3F61EA5A085289C

View file

@ -5,7 +5,7 @@ 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 f502b01b564bd33c449cbe621966ef4076a38cca..868951dc21aff541765b1f58f08cdf3c47446d25 100644
index f502b01b564bd33c449cbe621966ef4076a38cca..51d282b524b5249438f7744f7f0b1cc27b76470e 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -2099,7 +2099,23 @@ public class ServerLevel extends Level implements WorldGenLevel {
@ -20,12 +20,12 @@ index f502b01b564bd33c449cbe621966ef4076a38cca..868951dc21aff541765b1f58f08cdf3c
+ 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;
+ }
+
+ storage.cache.put(id, map);
+ }
+
+ return existing instanceof MapItemSavedData data ? data : null;