mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-04 10:11:29 +01:00
38 lines
3.2 KiB
Diff
38 lines
3.2 KiB
Diff
--- a/net/minecraft/server/ReloadableServerRegistries.java
|
|
+++ b/net/minecraft/server/ReloadableServerRegistries.java
|
|
@@ -48,8 +_,9 @@
|
|
List<HolderLookup.RegistryLookup<?>> list = TagLoader.buildUpdatedLookups(registryAccess.getAccessForLoading(RegistryLayer.RELOADABLE), postponedTags);
|
|
HolderLookup.Provider provider = HolderLookup.Provider.create(list.stream());
|
|
RegistryOps<JsonElement> registryOps = provider.createSerializationContext(JsonOps.INSTANCE);
|
|
+ final io.papermc.paper.registry.data.util.Conversions conversions = new io.papermc.paper.registry.data.util.Conversions(registryOps.lookupProvider); // Paper
|
|
List<CompletableFuture<WritableRegistry<?>>> list1 = LootDataType.values()
|
|
- .map(lootDataType -> scheduleRegistryLoad((LootDataType<?>)lootDataType, registryOps, resourceManager, backgroundExecutor))
|
|
+ .map(lootDataType -> scheduleRegistryLoad((LootDataType<?>)lootDataType, registryOps, resourceManager, backgroundExecutor, conversions)) // Paper
|
|
.toList();
|
|
CompletableFuture<List<WritableRegistry<?>>> completableFuture = Util.sequence(list1);
|
|
return completableFuture.thenApplyAsync(
|
|
@@ -58,19 +_,20 @@
|
|
}
|
|
|
|
private static <T> CompletableFuture<WritableRegistry<?>> scheduleRegistryLoad(
|
|
- LootDataType<T> lootDataType, RegistryOps<JsonElement> ops, ResourceManager resourceManager, Executor backgroundExecutor
|
|
+ LootDataType<T> lootDataType, RegistryOps<JsonElement> ops, ResourceManager resourceManager, Executor backgroundExecutor, io.papermc.paper.registry.data.util.Conversions conversions // Paper
|
|
) {
|
|
return CompletableFuture.supplyAsync(
|
|
() -> {
|
|
WritableRegistry<T> writableRegistry = new MappedRegistry<>(lootDataType.registryKey(), Lifecycle.experimental());
|
|
+ io.papermc.paper.registry.PaperRegistryAccess.instance().registerReloadableRegistry(lootDataType.registryKey(), writableRegistry); // Paper - register reloadable registry
|
|
Map<ResourceLocation, T> map = new HashMap<>();
|
|
SimpleJsonResourceReloadListener.scanDirectory(resourceManager, lootDataType.registryKey(), ops, lootDataType.codec(), map);
|
|
map.forEach(
|
|
- (resourceLocation, object) -> writableRegistry.register(
|
|
- ResourceKey.create(lootDataType.registryKey(), resourceLocation), (T)object, DEFAULT_REGISTRATION_INFO
|
|
+ (resourceLocation, object) -> io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.registerWithListeners(writableRegistry, // Paper - register with listeners
|
|
+ ResourceKey.create(lootDataType.registryKey(), resourceLocation), (T)object, DEFAULT_REGISTRATION_INFO, conversions // Paper - register with listeners
|
|
)
|
|
);
|
|
- TagLoader.loadTagsForRegistry(resourceManager, writableRegistry);
|
|
+ TagLoader.loadTagsForRegistry(resourceManager, writableRegistry, io.papermc.paper.plugin.lifecycle.event.registrar.ReloadableRegistrarEvent.Cause.RELOAD); // Paper - tag life cycle - reload
|
|
return writableRegistry;
|
|
},
|
|
backgroundExecutor
|