RegistryDataLoader .java

net.minecraft.resources.RegistryDataLoader (class, 347 lines): loads. members: SYNCHRONIZED_REGISTRIES, NetworkedRegistryData, RELOADABLE_REGISTRIES, load.

net.minecraft.resourcesclass347 linescommon21.6 KB

API Surface (7)

CompletableFuture<RegistryAccess.Frozen> load(final ResourceManager resourceManager, final List<HolderLookup.RegistryLookup<?>> contextRegistries, final List<RegistryDataLoader.RegistryData<?>> registriesToLoad, final Executor executor)
<T> RegistryLoadTask<T> create(final RegistryDataLoader.RegistryData<T> data, final Map<ResourceKey<?>, Exception> loadingErrors)
CompletableFuture<RegistryAccess.Frozen> load(final Map<ResourceKey<? extends Registry<?>>, RegistryDataLoader.NetworkedRegistryData> entries, final ResourceProvider knownDataSource, final List<HolderLookup.RegistryLookup<?>> contextRegistries, final List<RegistryDataLoader.RegistryData<?>> registriesToLoad, final Executor executor)
<T> RegistryLoadTask<T> create(final RegistryDataLoader.RegistryData<T> data, final Map<ResourceKey<?>, Exception> loadingErrors)
<T> Optional<HolderGetter<T>> lookup(final ResourceKey<? extends Registry<? extends T>> key)
record NetworkedRegistryData(List<RegistrySynchronization.PackedRegistryEntry> elements, TagNetworkSerialization.NetworkPayload tags)
void runWithArguments(final BiConsumer<ResourceKey<? extends Registry<T>>, Codec<T>> output)

Fields & Constants (12)

LOGGER
ERROR_KEY_COMPARATOR
WORLD_REGISTRIES
DIMENSION_REGISTRIES
RELOADABLE_REGISTRIES
SYNCHRONIZED_REGISTRIES
resourceManager
contextRegistries
registriesToLoad
entries
knownDataSource
loaderFactory

String literals (4)

"Failed to load registries due to errors"
"Registry Loading"
"Loading info"
"Errors"

Code Graph: Dependencies (76)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

RegistryDataLoader.java347 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.resources;
2
3
import com.mojang.logging.LogUtils;
4
import com.mojang.serialization.Codec;
5
import com.mojang.serialization.Lifecycle;
6
import java.io.PrintWriter;
7
import java.io.StringWriter;
8
import java.util.Comparator;
9
import java.util.HashMap;
10
import java.util.List;
11
import java.util.Locale;
12
import java.util.Map;
13
import java.util.Optional;
14
import java.util.Map.Entry;
15
import java.util.concurrent.CompletableFuture;
16
import java.util.concurrent.CompletionStage;
17
import java.util.concurrent.ConcurrentHashMap;
18
import java.util.concurrent.Executor;
19
import java.util.function.BiConsumer;
20
import java.util.stream.Collectors;
21
import net.minecraft.CrashReport;
22
import net.minecraft.CrashReportCategory;
23
import net.minecraft.ReportedException;
24
import net.minecraft.advancements.Advancement;
25
import net.minecraft.core.HolderGetter;
26
import net.minecraft.core.HolderLookup;
27
import net.minecraft.core.Registry;
28
import net.minecraft.core.RegistryAccess;
29
import net.minecraft.core.RegistrySynchronization;
30
import net.minecraft.core.component.BlockTransformer;
31
import net.minecraft.core.registries.Registries;
32
import net.minecraft.gametest.framework.GameTestInstance;
33
import net.minecraft.gametest.framework.TestEnvironmentDefinition;
34
import net.minecraft.network.chat.ChatType;
35
import net.minecraft.server.dialog.Dialog;
36
import net.minecraft.server.packs.resources.ResourceManager;
37
import net.minecraft.server.packs.resources.ResourceProvider;
38
import net.minecraft.tags.TagNetworkSerialization;
39
import net.minecraft.world.clock.WorldClock;
40
import net.minecraft.world.damagesource.DamageType;
41
import net.minecraft.world.entity.SulfurCubeArchetype;
42
import net.minecraft.world.entity.animal.chicken.ChickenSoundVariant;
43
import net.minecraft.world.entity.animal.chicken.ChickenVariant;
44
import net.minecraft.world.entity.animal.cow.CowSoundVariant;
45
import net.minecraft.world.entity.animal.cow.CowVariant;
46
import net.minecraft.world.entity.animal.feline.CatSoundVariant;
47
import net.minecraft.world.entity.animal.feline.CatVariant;
48
import net.minecraft.world.entity.animal.frog.FrogVariant;
49
import net.minecraft.world.entity.animal.nautilus.ZombieNautilusVariant;
50
import net.minecraft.world.entity.animal.pig.PigSoundVariant;
51
import net.minecraft.world.entity.animal.pig.PigVariant;
52
import net.minecraft.world.entity.animal.wolf.WolfSoundVariant;
53
import net.minecraft.world.entity.animal.wolf.WolfVariant;
54
import net.minecraft.world.entity.decoration.painting.PaintingVariant;
55
import net.minecraft.world.item.Instrument;
56
import net.minecraft.world.item.JukeboxSong;
57
import net.minecraft.world.item.crafting.Recipe;
58
import net.minecraft.world.item.enchantment.Enchantment;
59
import net.minecraft.world.item.enchantment.providers.EnchantmentProvider;
60
import net.minecraft.world.item.equipment.trim.TrimMaterial;
61
import net.minecraft.world.item.equipment.trim.TrimPattern;
62
import net.minecraft.world.item.slot.SlotSources;
63
import net.minecraft.world.item.trading.TradeSet;
64
import net.minecraft.world.item.trading.VillagerTrade;
65
import net.minecraft.world.level.biome.Biome;
66
import net.minecraft.world.level.biome.MultiNoiseBiomeSourceParameterList;
67
import net.minecraft.world.level.block.entity.BannerPattern;
68
import net.minecraft.world.level.block.entity.DecoratedPotPattern;
69
import net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerConfig;
70
import net.minecraft.world.level.dimension.DimensionType;
71
import net.minecraft.world.level.dimension.LevelStem;
72
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
73
import net.minecraft.world.level.levelgen.carver.WorldCarver;
74
import net.minecraft.world.level.levelgen.densityfunction.DensityFunctions;
75
import net.minecraft.world.level.levelgen.feature.Feature;
76
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
77
import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorPreset;
78
import net.minecraft.world.level.levelgen.material.condition.MaterialCondition;
79
import net.minecraft.world.level.levelgen.material.rule.MaterialRule;
80
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
81
import net.minecraft.world.level.levelgen.presets.WorldPreset;
82
import net.minecraft.world.level.levelgen.structure.Structure;
83
import net.minecraft.world.level.levelgen.structure.StructureSet;
84
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
85
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
86
import net.minecraft.world.level.levelgen.synth.NormalNoise;
87
import net.minecraft.world.level.storage.loot.LootTable;
88
import net.minecraft.world.level.storage.loot.functions.LootItemFunctions;
89
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
90
import net.minecraft.world.level.storage.loot.providers.number.floats.ContextFloatProviders;
91
import net.minecraft.world.level.storage.loot.providers.number.ints.ContextIntProviders;
92
import net.minecraft.world.timeline.Timeline;
93
import org.slf4j.Logger;
94
95
public class RegistryDataLoader {
96
	private static final Logger LOGGER = LogUtils.getLogger();
97
	private static final Comparator<ResourceKey<?>> ERROR_KEY_COMPARATOR = Comparator.comparing(ResourceKey::registry).thenComparing(ResourceKey::identifier);
98
	public static final List<RegistryDataLoader.RegistryData<?>> WORLD_REGISTRIES = List.of(
99
		new RegistryDataLoader.RegistryData<>(Registries.DIMENSION_TYPE, DimensionType.DIRECT_CODEC),
100
		new RegistryDataLoader.RegistryData<>(Registries.BIOME, Biome.DIRECT_CODEC),
101
		new RegistryDataLoader.RegistryData<>(Registries.CHAT_TYPE, ChatType.DIRECT_CODEC),
102
		new RegistryDataLoader.RegistryData<>(Registries.CARVER, WorldCarver.DIRECT_CODEC),
103
		new RegistryDataLoader.RegistryData<>(Registries.FEATURE, Feature.DIRECT_CODEC),
104
		new RegistryDataLoader.RegistryData<>(Registries.PLACED_FEATURE, PlacedFeature.DIRECT_CODEC),
105
		new RegistryDataLoader.RegistryData<>(Registries.STRUCTURE, Structure.DIRECT_CODEC),
106
		new RegistryDataLoader.RegistryData<>(Registries.STRUCTURE_SET, StructureSet.DIRECT_CODEC),
107
		new RegistryDataLoader.RegistryData<>(Registries.PROCESSOR_LIST, StructureProcessorType.DIRECT_CODEC),
108
		new RegistryDataLoader.RegistryData<>(Registries.TEMPLATE_POOL, StructureTemplatePool.DIRECT_CODEC),
109
		new RegistryDataLoader.RegistryData<>(Registries.NOISE_SETTINGS, NoiseGeneratorSettings.DIRECT_CODEC),
110
		new RegistryDataLoader.RegistryData<>(Registries.NOISE, NormalNoise.DIRECT_CODEC),
111
		new RegistryDataLoader.RegistryData<>(Registries.DENSITY_FUNCTION, DensityFunctions.DIRECT_CODEC),
112
		new RegistryDataLoader.RegistryData<>(Registries.MATERIAL_RULE, MaterialRule.DIRECT_CODEC),
113
		new RegistryDataLoader.RegistryData<>(Registries.MATERIAL_CONDITION, MaterialCondition.DIRECT_CODEC),
114
		new RegistryDataLoader.RegistryData<>(Registries.WORLD_PRESET, WorldPreset.DIRECT_CODEC),
115
		new RegistryDataLoader.RegistryData<>(Registries.FLAT_LEVEL_GENERATOR_PRESET, FlatLevelGeneratorPreset.DIRECT_CODEC),
116
		new RegistryDataLoader.RegistryData<>(Registries.TRIM_PATTERN, TrimPattern.DIRECT_CODEC),
117
		new RegistryDataLoader.RegistryData<>(Registries.TRIM_MATERIAL, TrimMaterial.DIRECT_CODEC),
118
		new RegistryDataLoader.RegistryData<>(Registries.TRIAL_SPAWNER_CONFIG, TrialSpawnerConfig.DIRECT_CODEC),
119
		new RegistryDataLoader.RegistryData<>(Registries.WOLF_VARIANT, WolfVariant.DIRECT_CODEC, RegistryValidator.nonEmpty()),
120
		new RegistryDataLoader.RegistryData<>(Registries.WOLF_SOUND_VARIANT, WolfSoundVariant.DIRECT_CODEC, RegistryValidator.nonEmpty()),
121
		new RegistryDataLoader.RegistryData<>(Registries.PIG_VARIANT, PigVariant.DIRECT_CODEC, RegistryValidator.nonEmpty()),
122
		new RegistryDataLoader.RegistryData<>(Registries.PIG_SOUND_VARIANT, PigSoundVariant.DIRECT_CODEC, RegistryValidator.nonEmpty()),
123
		new RegistryDataLoader.RegistryData<>(Registries.FROG_VARIANT, FrogVariant.DIRECT_CODEC, RegistryValidator.nonEmpty()),
124
		new RegistryDataLoader.RegistryData<>(Registries.CAT_VARIANT, CatVariant.DIRECT_CODEC, RegistryValidator.nonEmpty()),
125
		new RegistryDataLoader.RegistryData<>(Registries.CAT_SOUND_VARIANT, CatSoundVariant.DIRECT_CODEC, RegistryValidator.nonEmpty()),
126
		new RegistryDataLoader.RegistryData<>(Registries.COW_VARIANT, CowVariant.DIRECT_CODEC, RegistryValidator.nonEmpty()),
127
		new RegistryDataLoader.RegistryData<>(Registries.COW_SOUND_VARIANT, CowSoundVariant.DIRECT_CODEC, RegistryValidator.nonEmpty()),
128
		new RegistryDataLoader.RegistryData<>(Registries.SULFUR_CUBE_ARCHETYPE, SulfurCubeArchetype.DIRECT_CODEC),
129
		new RegistryDataLoader.RegistryData<>(Registries.CHICKEN_VARIANT, ChickenVariant.DIRECT_CODEC, RegistryValidator.nonEmpty()),
130
		new RegistryDataLoader.RegistryData<>(Registries.CHICKEN_SOUND_VARIANT, ChickenSoundVariant.DIRECT_CODEC, RegistryValidator.nonEmpty()),
131
		new RegistryDataLoader.RegistryData<>(Registries.ZOMBIE_NAUTILUS_VARIANT, ZombieNautilusVariant.DIRECT_CODEC, RegistryValidator.nonEmpty()),
132
		new RegistryDataLoader.RegistryData<>(Registries.PAINTING_VARIANT, PaintingVariant.DIRECT_CODEC, RegistryValidator.nonEmpty()),
133
		new RegistryDataLoader.RegistryData<>(Registries.DAMAGE_TYPE, DamageType.DIRECT_CODEC),
134
		new RegistryDataLoader.RegistryData<>(Registries.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST, MultiNoiseBiomeSourceParameterList.DIRECT_CODEC),
135
		new RegistryDataLoader.RegistryData<>(Registries.BANNER_PATTERN, BannerPattern.DIRECT_CODEC),
136
		new RegistryDataLoader.RegistryData<>(Registries.ENCHANTMENT, Enchantment.DIRECT_CODEC),
137
		new RegistryDataLoader.RegistryData<>(Registries.ENCHANTMENT_PROVIDER, EnchantmentProvider.DIRECT_CODEC),
138
		new RegistryDataLoader.RegistryData<>(Registries.JUKEBOX_SONG, JukeboxSong.DIRECT_CODEC),
139
		new RegistryDataLoader.RegistryData<>(Registries.INSTRUMENT, Instrument.DIRECT_CODEC),
140
		new RegistryDataLoader.RegistryData<>(Registries.TEST_ENVIRONMENT, TestEnvironmentDefinition.DIRECT_CODEC),
141
		new RegistryDataLoader.RegistryData<>(Registries.TEST_INSTANCE, GameTestInstance.DIRECT_CODEC),
142
		new RegistryDataLoader.RegistryData<>(Registries.DIALOG, Dialog.DIRECT_CODEC),
143
		new RegistryDataLoader.RegistryData<>(Registries.WORLD_CLOCK, WorldClock.DIRECT_CODEC),
144
		new RegistryDataLoader.RegistryData<>(Registries.TIMELINE, Timeline.DIRECT_CODEC, Timeline::validateRegistry),
145
		new RegistryDataLoader.RegistryData<>(Registries.VILLAGER_TRADE, VillagerTrade.CODEC),
146
		new RegistryDataLoader.RegistryData<>(Registries.TRADE_SET, TradeSet.CODEC),
147
		new RegistryDataLoader.RegistryData<>(Registries.DECORATED_POT_PATTERN, DecoratedPotPattern.CODEC),
148
		new RegistryDataLoader.RegistryData<>(Registries.BLOCK_TRANSFORMER, BlockTransformer.DIRECT_CODEC),
149
		new RegistryDataLoader.RegistryData<>(Registries.BLOCK_STATE_PROVIDER, BlockStateProvider.DIRECT_CODEC)
150
	);
151
	public static final List<RegistryDataLoader.RegistryData<?>> DIMENSION_REGISTRIES = List.of(
152
		new RegistryDataLoader.RegistryData<>(Registries.LEVEL_STEM, LevelStem.CODEC)
153
	);
154
	public static final List<RegistryDataLoader.RegistryData<?>> RELOADABLE_REGISTRIES = List.of(
155
		new RegistryDataLoader.RegistryData<>(Registries.LOOT_TABLE, LootTable.DIRECT_CODEC),
156
		new RegistryDataLoader.RegistryData<>(Registries.PREDICATE, LootItemCondition.DIRECT_CODEC),
157
		new RegistryDataLoader.RegistryData<>(Registries.CONTEXT_FLOAT_PROVIDER, ContextFloatProviders.DIRECT_CODEC),
158
		new RegistryDataLoader.RegistryData<>(Registries.CONTEXT_INT_PROVIDER, ContextIntProviders.DIRECT_CODEC),
159
		new RegistryDataLoader.RegistryData<>(Registries.ITEM_MODIFIER, LootItemFunctions.TYPED_CODEC),
160
		new RegistryDataLoader.RegistryData<>(Registries.SLOT_SOURCE, SlotSources.TYPED_CODEC),
161
		new RegistryDataLoader.RegistryData<>(Registries.ADVANCEMENT, Advancement.CODEC),
162
		new RegistryDataLoader.RegistryData<>(Registries.RECIPE, Recipe.DIRECT_CODEC)
163
	);
164
	public static final List<RegistryDataLoader.RegistryData<?>> SYNCHRONIZED_REGISTRIES = List.of(
165
		new RegistryDataLoader.RegistryData<>(Registries.BIOME, Biome.NETWORK_CODEC),
166
		new RegistryDataLoader.RegistryData<>(Registries.CHAT_TYPE, ChatType.DIRECT_CODEC),
167
		new RegistryDataLoader.RegistryData<>(Registries.TRIM_PATTERN, TrimPattern.DIRECT_CODEC),
168
		new RegistryDataLoader.RegistryData<>(Registries.TRIM_MATERIAL, TrimMaterial.DIRECT_CODEC),
169
		new RegistryDataLoader.RegistryData<>(Registries.WOLF_VARIANT, WolfVariant.NETWORK_CODEC, RegistryValidator.nonEmpty()),
170
		new RegistryDataLoader.RegistryData<>(Registries.WOLF_SOUND_VARIANT, WolfSoundVariant.NETWORK_CODEC, RegistryValidator.nonEmpty()),
171
		new RegistryDataLoader.RegistryData<>(Registries.PIG_VARIANT, PigVariant.NETWORK_CODEC, RegistryValidator.nonEmpty()),
172
		new RegistryDataLoader.RegistryData<>(Registries.PIG_SOUND_VARIANT, PigSoundVariant.NETWORK_CODEC, RegistryValidator.nonEmpty()),
173
		new RegistryDataLoader.RegistryData<>(Registries.FROG_VARIANT, FrogVariant.NETWORK_CODEC, RegistryValidator.nonEmpty()),
174
		new RegistryDataLoader.RegistryData<>(Registries.CAT_VARIANT, CatVariant.NETWORK_CODEC, RegistryValidator.nonEmpty()),
175
		new RegistryDataLoader.RegistryData<>(Registries.CAT_SOUND_VARIANT, CatSoundVariant.NETWORK_CODEC, RegistryValidator.nonEmpty()),
176
		new RegistryDataLoader.RegistryData<>(Registries.COW_SOUND_VARIANT, CowSoundVariant.DIRECT_CODEC, RegistryValidator.nonEmpty()),
177
		new RegistryDataLoader.RegistryData<>(Registries.COW_VARIANT, CowVariant.NETWORK_CODEC, RegistryValidator.nonEmpty()),
178
		new RegistryDataLoader.RegistryData<>(Registries.CHICKEN_SOUND_VARIANT, ChickenSoundVariant.DIRECT_CODEC, RegistryValidator.nonEmpty()),
179
		new RegistryDataLoader.RegistryData<>(Registries.CHICKEN_VARIANT, ChickenVariant.NETWORK_CODEC, RegistryValidator.nonEmpty()),
180
		new RegistryDataLoader.RegistryData<>(Registries.ZOMBIE_NAUTILUS_VARIANT, ZombieNautilusVariant.NETWORK_CODEC, RegistryValidator.nonEmpty()),
181
		new RegistryDataLoader.RegistryData<>(Registries.PAINTING_VARIANT, PaintingVariant.DIRECT_CODEC, RegistryValidator.nonEmpty()),
182
		new RegistryDataLoader.RegistryData<>(Registries.SULFUR_CUBE_ARCHETYPE, SulfurCubeArchetype.DIRECT_CODEC),
183
		new RegistryDataLoader.RegistryData<>(Registries.DIMENSION_TYPE, DimensionType.NETWORK_CODEC),
184
		new RegistryDataLoader.RegistryData<>(Registries.DAMAGE_TYPE, DamageType.DIRECT_CODEC),
185
		new RegistryDataLoader.RegistryData<>(Registries.BANNER_PATTERN, BannerPattern.DIRECT_CODEC),
186
		new RegistryDataLoader.RegistryData<>(Registries.ENCHANTMENT, Enchantment.DIRECT_CODEC),
187
		new RegistryDataLoader.RegistryData<>(Registries.JUKEBOX_SONG, JukeboxSong.DIRECT_CODEC),
188
		new RegistryDataLoader.RegistryData<>(Registries.INSTRUMENT, Instrument.DIRECT_CODEC),
189
		new RegistryDataLoader.RegistryData<>(Registries.TEST_ENVIRONMENT, TestEnvironmentDefinition.DIRECT_CODEC),
190
		new RegistryDataLoader.RegistryData<>(Registries.TEST_INSTANCE, GameTestInstance.DIRECT_CODEC),
191
		new RegistryDataLoader.RegistryData<>(Registries.DIALOG, Dialog.DIRECT_CODEC),
192
		new RegistryDataLoader.RegistryData<>(Registries.WORLD_CLOCK, WorldClock.DIRECT_CODEC),
193
		new RegistryDataLoader.RegistryData<>(Registries.TIMELINE, Timeline.NETWORK_CODEC),
194
		new RegistryDataLoader.RegistryData<>(Registries.DECORATED_POT_PATTERN, DecoratedPotPattern.CODEC),
195
		new RegistryDataLoader.RegistryData<>(Registries.BLOCK_TRANSFORMER, BlockTransformer.DIRECT_CODEC),
196
		new RegistryDataLoader.RegistryData<>(Registries.BLOCK_STATE_PROVIDER, BlockStateProvider.DIRECT_CODEC)
197
	);
198
199
	public static CompletableFuture<RegistryAccess.Frozen> load(
200
		final ResourceManager resourceManager,
201
		final List<HolderLookup.RegistryLookup<?>> contextRegistries,
202
		final List<RegistryDataLoader.RegistryData<?>> registriesToLoad,
203
		final Executor executor
204
	) {
205
		RegistryDataLoader.LoaderFactory loaderFactory = new RegistryDataLoader.LoaderFactory() {
206
			@Override
207
			public <T> RegistryLoadTask<T> create(final RegistryDataLoader.RegistryData<T> data, final Map<ResourceKey<?>, Exception> loadingErrors) {
208
				return new ResourceManagerRegistryLoadTask<>(data, Lifecycle.stable(), loadingErrors, resourceManager);
209
			}
210
		};
211
		return load(loaderFactory, contextRegistries, registriesToLoad, executor);
212
	}
213
214
	public static CompletableFuture<RegistryAccess.Frozen> load(
215
		final Map<ResourceKey<? extends Registry<?>>, RegistryDataLoader.NetworkedRegistryData> entries,
216
		final ResourceProvider knownDataSource,
217
		final List<HolderLookup.RegistryLookup<?>> contextRegistries,
218
		final List<RegistryDataLoader.RegistryData<?>> registriesToLoad,
219
		final Executor executor
220
	) {
221
		RegistryDataLoader.LoaderFactory loaderFactory = new RegistryDataLoader.LoaderFactory() {
222
			@Override
223
			public <T> RegistryLoadTask<T> create(final RegistryDataLoader.RegistryData<T> data, final Map<ResourceKey<?>, Exception> loadingErrors) {
224
				return new NetworkRegistryLoadTask<>(data, Lifecycle.stable(), loadingErrors, entries, knownDataSource);
225
			}
226
		};
227
		return load(loaderFactory, contextRegistries, registriesToLoad, executor);
228
	}
229
230
	private static CompletableFuture<RegistryAccess.Frozen> load(
231
		final RegistryDataLoader.LoaderFactory loaderFactory,
232
		final List<HolderLookup.RegistryLookup<?>> contextRegistries,
233
		final List<RegistryDataLoader.RegistryData<?>> registriesToLoad,
234
		final Executor executor
235
	) {
236
		return CompletableFuture.<CompletableFuture<RegistryAccess.Frozen>>supplyAsync(
237
				() -> {
238
					Map<ResourceKey<?>, Exception> loadingErrors = new ConcurrentHashMap<>();
239
					List<RegistryLoadTask<?>> loadTasks = registriesToLoad.stream()
240
						.map(r -> loaderFactory.create((RegistryDataLoader.RegistryData<?>)r, loadingErrors))
241
						.collect(Collectors.toUnmodifiableList());
242
					RegistryOps.RegistryInfoLookup contextAndNewRegistries = createContext(contextRegistries, loadTasks);
243
					int taskCount = loadTasks.size();
244
					CompletableFuture<?>[] loadCompletions = new CompletableFuture[taskCount];
245
246
					for (int i = 0; i < taskCount; i++) {
247
						loadCompletions[i] = loadTasks.get(i).load(contextAndNewRegistries, executor);
248
					}
249
250
					return CompletableFuture.allOf(loadCompletions).thenApplyAsync(ignored -> {
251
						List<RegistryLoadTask<?>> frozenRegistries = loadTasks.stream().filter(task -> task.freezeRegistry(loadingErrors)).toList();
252
						if (!loadingErrors.isEmpty()) {
253
							throw logErrors(loadingErrors);
254
						} else {
255
							List<? extends Registry<?>> registries = frozenRegistries.stream().flatMap(task -> task.validateRegistry(loadingErrors).stream()).toList();
256
							if (!loadingErrors.isEmpty()) {
257
								throw logErrors(loadingErrors);
258
							} else {
259
								return new RegistryAccess.ImmutableRegistryAccess(registries).freeze();
260
							}
261
						}
262
					}, executor);
263
				},
264
				executor
265
			)
266
			.thenCompose(c -> (CompletionStage<RegistryAccess.Frozen>)c);
267
	}
268
269
	private static RegistryOps.RegistryInfoLookup createContext(
270
		final List<HolderLookup.RegistryLookup<?>> contextRegistries, final List<RegistryLoadTask<?>> newRegistriesAndLoaders
271
	) {
272
		final Map<ResourceKey<? extends Registry<?>>, HolderGetter<?>> result = new HashMap<>();
273
		contextRegistries.forEach(e -> result.put(e.key(), e));
274
		newRegistriesAndLoaders.forEach(e -> result.put(e.registryKey(), e.concurrentRegistrationGetter));
275
		return new RegistryOps.RegistryInfoLookup() {
276
			@Override
277
			public <T> Optional<HolderGetter<T>> lookup(final ResourceKey<? extends Registry<? extends T>> key) {
278
				return Optional.ofNullable((HolderGetter<T>)result.get(key));
279
			}
280
		};
281
	}
282
283
	private static ReportedException logErrors(final Map<ResourceKey<?>, Exception> loadingErrors) {
284
		printFullDetailsToLog(loadingErrors);
285
		return createReportWithBriefInfo(loadingErrors);
286
	}
287
288
	private static void printFullDetailsToLog(final Map<ResourceKey<?>, Exception> loadingErrors) {
289
		StringWriter collectedErrors = new StringWriter();
290
		PrintWriter errorPrinter = new PrintWriter(collectedErrors);
291
		Map<Identifier, Map<Identifier, Exception>> errorsByRegistry = loadingErrors.entrySet()
292
			.stream()
293
			.collect(Collectors.groupingBy(e -> e.getKey().registry(), Collectors.toMap(e -> e.getKey().identifier(), Entry::getValue)));
294
		errorsByRegistry.entrySet().stream().sorted(Entry.comparingByKey()).forEach(registryEntry -> {
295
			errorPrinter.printf(Locale.ROOT, "> Errors in registry %s:%n", registryEntry.getKey());
296
			registryEntry.getValue().entrySet().stream().sorted(Entry.comparingByKey()).forEach(elementError -> {
297
				errorPrinter.printf(Locale.ROOT, ">> Errors in element %s:%n", elementError.getKey());
298
				elementError.getValue().printStackTrace(errorPrinter);
299
			});
300
		});
301
		errorPrinter.flush();
302
		LOGGER.error("Registry loading errors:\n{}", collectedErrors);
303
	}
304
305
	private static ReportedException createReportWithBriefInfo(final Map<ResourceKey<?>, Exception> loadingErrors) {
306
		CrashReport report = CrashReport.forThrowable(new IllegalStateException("Failed to load registries due to errors"), "Registry Loading");
307
		CrashReportCategory errors = report.addCategory("Loading info");
308
		errors.setDetail(
309
			"Errors",
310
			() -> {
311
				StringBuilder briefDetails = new StringBuilder();
312
				loadingErrors.entrySet()
313
					.stream()
314
					.sorted(Entry.comparingByKey(ERROR_KEY_COMPARATOR))
315
					.forEach(
316
						e -> briefDetails.append("\n\t\t")
317
							.append(e.getKey().registry())
318
							.append("/")
319
							.append(e.getKey().identifier())
320
							.append(": ")
321
							.append(e.getValue().getMessage())
322
					);
323
				return briefDetails.toString();
324
			}
325
		);
326
		return new ReportedException(report);
327
	}
328
329
	@FunctionalInterface
330
	private interface LoaderFactory {
331
		<T> RegistryLoadTask<T> create(RegistryDataLoader.RegistryData<T> data, Map<ResourceKey<?>, Exception> loadingErrors);
332
	}
333
334
	public record NetworkedRegistryData(List<RegistrySynchronization.PackedRegistryEntry> elements, TagNetworkSerialization.NetworkPayload tags) {
335
	}
336
337
	public record RegistryData<T>(ResourceKey<? extends Registry<T>> key, Codec<T> elementCodec, RegistryValidator<T> validator) {
338
		private RegistryData(final ResourceKey<? extends Registry<T>> key, final Codec<T> elementCodec) {
339
			this(key, elementCodec, RegistryValidator.none());
340
		}
341
342
		public void runWithArguments(final BiConsumer<ResourceKey<? extends Registry<T>>, Codec<T>> output) {
343
			output.accept(this.key, this.elementCodec);
344
		}
345
	}
346
}
347

Decompiled Minecraft 26.3 source of RegistryDataLoader (net/minecraft/resources/RegistryDataLoader.java) with Mojang official mappings, stored verbatim on the site.