[1.19] Fix data-gen output path of custom data-pack registries (#8724)

This commit is contained in:
Silverminer007 authored and GitHub committed 2022-06-15 16:22:00 +01:00
1 parent 48341120fb
commit 5acfc6ae3c
4 files changed
+42 -7

No files matched your search

@@ -1419,4 +1419,29 @@ public class ForgeHooks
return map.buildOrThrow();
}
/**
* <p>
* This method is used to prefix the path, where elements of the associated registry are stored, with their namespace, if it is not minecraft
* </p>
* <p>
* This rules conflicts with equal paths out. If for example the mod {@code fancy_cheese} adds a registry named {@code cheeses},
* but the mod {@code awesome_cheese} also adds a registry called {@code cheeses},
* they are going to have the same path {@code cheeses}, just with different namespaces.
* If {@code additional_cheese} wants to add additional cheese to {@code awesome_cheese}, but not {@code fancy_cheese},
* it can not differentiate both. Both paths will look like {@code data/additional_cheese/cheeses}.
* </p>
* <p>
* The fix, which is applied here prefixes the path of the registry with the namespace,
* so {@code fancy_cheese}'s registry stores its elements in {@code data/<namespace>/fancy_cheese/cheeses}
* and {@code awesome_cheese}'s registry stores its elements in {@code data/namespace/awesome_cheese/cheeses}
* </p>
*
* @param registryKey key of the registry
* @return path of the registry key. Prefixed with the namespace if it is not "minecraft"
*/
public static String prefixNamespace(ResourceLocation registryKey)
{
return registryKey.getNamespace().equals("minecraft") ? registryKey.getPath() : registryKey.getNamespace() + "/" + registryKey.getPath();
}
}