diff --git a/src/main/java/com/simibubi/create/foundation/data/LangMerger.java b/src/main/java/com/simibubi/create/foundation/data/LangMerger.java index 8cdb56bb0..16a357628 100644 --- a/src/main/java/com/simibubi/create/foundation/data/LangMerger.java +++ b/src/main/java/com/simibubi/create/foundation/data/LangMerger.java @@ -28,10 +28,12 @@ import com.tterrag.registrate.providers.ProviderType; import net.minecraft.Util; import net.minecraft.data.CachedOutput; +import net.minecraft.data.DataGenerator; import net.minecraft.data.DataProvider; import net.minecraft.data.PackOutput; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.GsonHelper; +import net.minecraftforge.fml.util.ObfuscationReflectionHelper; /** * @deprecated Use {@link AbstractRegistrate#addRawLang} or {@link AbstractRegistrate#addDataGenerator} with {@link ProviderType#LANG} instead. @@ -64,6 +66,18 @@ public class LangMerger implements DataProvider { populateLangIgnore(); } + public static void attachToRegistrateProvider(DataGenerator gen, PackOutput output) { + Map providers = + ObfuscationReflectionHelper.getPrivateValue(DataGenerator.class, gen, "providersToRun"); + Entry entryToReplace = null; + for (Entry entry : providers.entrySet()) + if (entry.getValue() instanceof RegistrateDataProvider rdp) + entryToReplace = entry; + if (entryToReplace != null) + providers.put(entryToReplace.getKey(), new ChainedDataProvider(entryToReplace.getValue(), + new LangMerger(output, Create.ID, Create.NAME, AllLangPartials.values()))); + } + protected void populateLangIgnore() { // Key prefixes added here will NOT be transferred to lang templates langIgnore.add("create.ponder.debug_"); // Ponder debug scene text