From 915637df5cac63362bdea1db8613068b4983de88 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sat, 23 Nov 2024 10:52:00 -0800 Subject: Run 'freeze' listeners before tag events (#11606) --- patches/server/0992-Registry-Modification-API.patch | 21 +++++++++++++-------- patches/server/1020-Tag-Lifecycle-Events.patch | 4 ++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/patches/server/0992-Registry-Modification-API.patch b/patches/server/0992-Registry-Modification-API.patch index bd82d9ecf8..8a255ef743 100644 --- a/patches/server/0992-Registry-Modification-API.patch +++ b/patches/server/0992-Registry-Modification-API.patch @@ -1174,7 +1174,7 @@ index 4638ba98dbbdb0f880337347be85a6e0fbed2191..bc448f8511c629d1f13d4baf717a11e6 } } diff --git a/src/main/java/net/minecraft/resources/RegistryDataLoader.java b/src/main/java/net/minecraft/resources/RegistryDataLoader.java -index 61774165a25209ee6d26cf8d80149b220c3874e6..fdc88e52235a152dbe3cca273990b4b68f8daaf8 100644 +index 61774165a25209ee6d26cf8d80149b220c3874e6..c5e279216f6cb880397ea2768ee6e99a8798e3e1 100644 --- a/src/main/java/net/minecraft/resources/RegistryDataLoader.java +++ b/src/main/java/net/minecraft/resources/RegistryDataLoader.java @@ -130,7 +130,7 @@ public class RegistryDataLoader { @@ -1195,7 +1195,7 @@ index 61774165a25209ee6d26cf8d80149b220c3874e6..fdc88e52235a152dbe3cca273990b4b6 } private static RegistryAccess.Frozen load( -@@ -148,9 +148,11 @@ public class RegistryDataLoader { +@@ -148,7 +148,8 @@ public class RegistryDataLoader { Map, Exception> map = new HashMap<>(); List> list = entries.stream().map(entry -> entry.create(Lifecycle.stable(), map)).collect(Collectors.toUnmodifiableList()); RegistryOps.RegistryInfoLookup registryInfoLookup = createContext(registries, list); @@ -1204,11 +1204,8 @@ index 61774165a25209ee6d26cf8d80149b220c3874e6..fdc88e52235a152dbe3cca273990b4b6 + list.forEach(loader -> loadable.apply((RegistryDataLoader.Loader)loader, registryInfoLookup, conversions)); list.forEach(loader -> { Registry registry = loader.registry(); -+ io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.runFreezeListeners(loader.registry.key(), conversions); // Paper - run pre-freeze listeners - try { - registry.freeze(); -@@ -238,13 +240,13 @@ public class RegistryDataLoader { +@@ -238,13 +239,13 @@ public class RegistryDataLoader { } private static void loadElementFromResource( @@ -1224,7 +1221,7 @@ index 61774165a25209ee6d26cf8d80149b220c3874e6..fdc88e52235a152dbe3cca273990b4b6 } } -@@ -253,7 +255,8 @@ public class RegistryDataLoader { +@@ -253,7 +254,8 @@ public class RegistryDataLoader { RegistryOps.RegistryInfoLookup infoGetter, WritableRegistry registry, Decoder elementDecoder, @@ -1234,7 +1231,7 @@ index 61774165a25209ee6d26cf8d80149b220c3874e6..fdc88e52235a152dbe3cca273990b4b6 ) { String string = Registries.elementsDirPath(registry.key()); FileToIdConverter fileToIdConverter = FileToIdConverter.json(string); -@@ -266,7 +269,7 @@ public class RegistryDataLoader { +@@ -266,7 +268,7 @@ public class RegistryDataLoader { RegistrationInfo registrationInfo = REGISTRATION_INFO_CACHE.apply(resource.knownPackInfo()); try { @@ -1243,6 +1240,14 @@ index 61774165a25209ee6d26cf8d80149b220c3874e6..fdc88e52235a152dbe3cca273990b4b6 } catch (Exception var15) { errors.put( resourceKey, +@@ -275,6 +277,7 @@ public class RegistryDataLoader { + } + } + ++ io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.runFreezeListeners(registry.key(), conversions); // Paper - run pre-freeze listeners + TagLoader.loadTagsForRegistry(resourceManager, registry); + } + @@ -284,7 +287,8 @@ public class RegistryDataLoader { RegistryOps.RegistryInfoLookup infoGetter, WritableRegistry registry, diff --git a/patches/server/1020-Tag-Lifecycle-Events.patch b/patches/server/1020-Tag-Lifecycle-Events.patch index 6b65432932..593b77a3f1 100644 --- a/patches/server/1020-Tag-Lifecycle-Events.patch +++ b/patches/server/1020-Tag-Lifecycle-Events.patch @@ -461,13 +461,13 @@ index 0000000000000000000000000000000000000000..d6d4bfc6f45d646afeace422a038c670 +) { +} diff --git a/src/main/java/net/minecraft/resources/RegistryDataLoader.java b/src/main/java/net/minecraft/resources/RegistryDataLoader.java -index fdc88e52235a152dbe3cca273990b4b68f8daaf8..13797035494a1e010e1da529fb46040f8a6e859f 100644 +index c5e279216f6cb880397ea2768ee6e99a8798e3e1..46bf2b95658ca3bbd3048df5f8adf1bdcc2d3571 100644 --- a/src/main/java/net/minecraft/resources/RegistryDataLoader.java +++ b/src/main/java/net/minecraft/resources/RegistryDataLoader.java @@ -278,7 +278,7 @@ public class RegistryDataLoader { - } } + io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.runFreezeListeners(registry.key(), conversions); // Paper - run pre-freeze listeners - TagLoader.loadTagsForRegistry(resourceManager, registry); + TagLoader.loadTagsForRegistry(resourceManager, registry, io.papermc.paper.plugin.lifecycle.event.registrar.ReloadableRegistrarEvent.Cause.INITIAL); // Paper - tag lifecycle - add cause } -- cgit v1.2.3