Skip to content

Commit

Permalink
Add stopguard on registering dynamic registries
Browse files Browse the repository at this point in the history
No, you cannot use the `minecraft` namespace and blow up the world
  • Loading branch information
EnnuiL committed Aug 1, 2023
1 parent 995fb0d commit c63c489
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ public static boolean isModdedRegistryId(Identifier id) {
}

public static <E> void register(RegistryKey<? extends Registry<E>> ref, Codec<E> entryCodec, DynamicRegistryFlag... flags) {
if (ref.getValue().getNamespace().equals(Identifier.DEFAULT_NAMESPACE)) {
throw new IllegalStateException("The '" + ref.getValue() + "' dynamic registry cannot have 'minecraft' as its identifier's namespace!");
}

if (frozen) throw new IllegalStateException("Registry is already frozen");

MODDED_REGISTRY_IDS.add(ref.getValue());
RegistryLoader.WORLDGEN_REGISTRIES.add(new RegistryLoader.DecodingData<>(ref, entryCodec));
for (DynamicRegistryFlag flag : flags) {
Expand Down

0 comments on commit c63c489

Please sign in to comment.