From c63c4893af453974f3798e9315cb05cb0a03b35a Mon Sep 17 00:00:00 2001 From: Ennui Langeweile <85590273+EnnuiL@users.noreply.github.com> Date: Mon, 31 Jul 2023 22:00:27 -0300 Subject: [PATCH] Add stopguard on registering dynamic registries No, you cannot use the `minecraft` namespace and blow up the world --- .../qsl/registry/impl/dynamic/DynamicMetaRegistryImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/core/registry/src/main/java/org/quiltmc/qsl/registry/impl/dynamic/DynamicMetaRegistryImpl.java b/library/core/registry/src/main/java/org/quiltmc/qsl/registry/impl/dynamic/DynamicMetaRegistryImpl.java index b6304e1548..8fd0b2edab 100644 --- a/library/core/registry/src/main/java/org/quiltmc/qsl/registry/impl/dynamic/DynamicMetaRegistryImpl.java +++ b/library/core/registry/src/main/java/org/quiltmc/qsl/registry/impl/dynamic/DynamicMetaRegistryImpl.java @@ -45,7 +45,12 @@ public static boolean isModdedRegistryId(Identifier id) { } public static void register(RegistryKey> ref, Codec 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) {