Restore LangMerger#attachToRegistrateProvider

This commit is contained in:
PepperCode1 2023-09-21 09:29:40 -07:00
parent f8bd8d641d
commit 992373236e

View File

@ -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<String, DataProvider> providers =
ObfuscationReflectionHelper.getPrivateValue(DataGenerator.class, gen, "providersToRun");
Entry<String, DataProvider> entryToReplace = null;
for (Entry<String, DataProvider> 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