[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

@@ -0,0 +1,11 @@
--- a/net/minecraft/data/info/WorldgenRegistryDumpReport.java
+++ b/net/minecraft/data/info/WorldgenRegistryDumpReport.java
@@ -37,7 +_,7 @@
private <T> void m_236204_(CachedOutput p_236205_, RegistryAccess p_236206_, DynamicOps<JsonElement> p_236207_, RegistryAccess.RegistryData<T> p_236208_) {
ResourceKey<? extends Registry<T>> resourcekey = p_236208_.f_123101_();
Registry<T> registry = p_236206_.m_206191_(resourcekey);
- DataGenerator.PathProvider datagenerator$pathprovider = this.f_194676_.m_236036_(DataGenerator.Target.REPORTS, resourcekey.m_135782_().m_135815_());
+ DataGenerator.PathProvider datagenerator$pathprovider = this.f_194676_.m_236036_(DataGenerator.Target.REPORTS, net.minecraftforge.common.ForgeHooks.prefixNamespace(resourcekey.m_135782_())); // FORGE: Custom data-pack registries are prefixed with their namespace
for(Map.Entry<ResourceKey<T>, T> entry : registry.m_6579_()) {
m_236209_(datagenerator$pathprovider.m_236048_(entry.getKey().m_135782_()), p_236205_, p_236207_, p_236208_.f_123102_(), entry.getValue());
@@ -18,7 +18,7 @@
} catch (Throwable throwable1) {
if (reader != null) {
try {
@@ -107,12 +_,15 @@
@@ -107,13 +_,14 @@
});
}
@@ -30,8 +30,8 @@
}
private static String m_214239_(ResourceLocation p_214240_) {
+ if (net.minecraftforge.registries.RegistryManager.FROZEN.getRegistry(p_214240_) != null && !(p_214240_.m_135827_().equals("minecraft")))
+ return p_214240_.m_135827_() + "/" + p_214240_.m_135815_(); // FORGE: add non-vanilla registry namespace to loader directory, same format as tag directory (see net.minecraft.tags.TagManager#getTagDir(ResourceKey))
return p_214240_.m_135815_();
- return p_214240_.m_135815_();
+ return net.minecraftforge.common.ForgeHooks.prefixNamespace(p_214240_); // FORGE: add non-vanilla registry namespace to loader directory, same format as tag directory (see net.minecraft.tags.TagManager#getTagDir(ResourceKey))
}
private static <E> ResourceLocation m_214268_(ResourceKey<E> p_214269_) {
@@ -1,12 +1,11 @@
--- a/net/minecraft/tags/TagManager.java
+++ b/net/minecraft/tags/TagManager.java
@@ -30,7 +_,8 @@
@@ -30,7 +_,7 @@
public static String m_203918_(ResourceKey<? extends Registry<?>> p_203919_) {
String s = f_203902_.get(p_203919_);
- return s != null ? s : "tags/" + p_203919_.m_135782_().m_135815_();
+ ResourceLocation registryName = p_203919_.m_135782_();
+ return s != null ? s : "tags/" + (registryName.m_135827_().equals("minecraft") ? "" : registryName.m_135827_() + "/") + registryName.m_135815_();
+ return s != null ? s : "tags/" + net.minecraftforge.common.ForgeHooks.prefixNamespace(p_203919_.m_135782_());
}
public CompletableFuture<Void> m_5540_(PreparableReloadListener.PreparationBarrier p_13482_, ResourceManager p_13483_, ProfilerFiller p_13484_, ProfilerFiller p_13485_, Executor p_13486_, Executor p_13487_) {
@@ -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();
}
}