|
1 | 1 | package org.embeddedt.modernfix.forge.init; |
2 | 2 |
|
| 3 | +import com.google.common.collect.ImmutableList; |
3 | 4 | import net.minecraft.world.item.Item; |
4 | 5 | import net.minecraftforge.api.distmarker.Dist; |
5 | 6 | import net.minecraftforge.common.MinecraftForge; |
|
20 | 21 | import net.minecraftforge.registries.ForgeRegistries; |
21 | 22 | import org.apache.commons.lang3.tuple.Pair; |
22 | 23 | import org.embeddedt.modernfix.ModernFix; |
| 24 | +import org.embeddedt.modernfix.core.ModernFixMixinPlugin; |
23 | 25 | import org.embeddedt.modernfix.forge.classloading.ClassLoadHack; |
24 | 26 | import org.embeddedt.modernfix.forge.classloading.ModFileScanDataDeduplicator; |
25 | 27 | import org.embeddedt.modernfix.forge.ModernFixConfig; |
|
29 | 31 | import org.embeddedt.modernfix.forge.registry.ObjectHolderClearer; |
30 | 32 | import org.embeddedt.modernfix.forge.util.KubeUtil; |
31 | 33 |
|
| 34 | +import java.util.List; |
| 35 | + |
32 | 36 | @Mod(ModernFix.MODID) |
33 | 37 | public class ModernFixForge { |
34 | 38 | private static ModernFix commonMod; |
@@ -68,19 +72,25 @@ private void registerItems(RegistryEvent<Item> event) { |
68 | 72 | } |
69 | 73 | } |
70 | 74 |
|
71 | | - private static boolean dfuModPresent() { |
72 | | - for(String modId : new String[] { "lazydfu", "datafixerslayer" }) { |
73 | | - if(ModList.get().isLoaded(modId)) |
74 | | - return true; |
75 | | - } |
76 | | - return !FMLLoader.isProduction(); |
77 | | - } |
| 75 | + private static final List<Pair<List<String>, String>> MOD_WARNINGS = ImmutableList.of( |
| 76 | + Pair.of(ImmutableList.of("lazydfu", "datafixerslayer"), "modernfix.no_lazydfu"), |
| 77 | + Pair.of(ImmutableList.of("ferritecore"), "modernfix.no_ferritecore") |
| 78 | + ); |
78 | 79 |
|
79 | 80 | @SubscribeEvent |
80 | 81 | public void commonSetup(FMLCommonSetupEvent event) { |
81 | | - if(!dfuModPresent()) { |
| 82 | + if(ModernFixMixinPlugin.instance.isOptionEnabled("feature.warn_missing_perf_mods.Warnings")) { |
82 | 83 | event.enqueueWork(() -> { |
83 | | - ModLoader.get().addWarning(new ModLoadingWarning(ModLoadingContext.get().getActiveContainer().getModInfo(), ModLoadingStage.COMMON_SETUP, "modernfix.no_lazydfu")); |
| 84 | + boolean atLeastOneWarning = false; |
| 85 | + for(Pair<List<String>, String> warning : MOD_WARNINGS) { |
| 86 | + boolean isPresent = !FMLLoader.isProduction() || warning.getLeft().stream().anyMatch(name -> ModList.get().isLoaded(name)); |
| 87 | + if(!isPresent) { |
| 88 | + atLeastOneWarning = true; |
| 89 | + ModLoader.get().addWarning(new ModLoadingWarning(ModLoadingContext.get().getActiveContainer().getModInfo(), ModLoadingStage.COMMON_SETUP, warning.getRight())); |
| 90 | + } |
| 91 | + } |
| 92 | + if(atLeastOneWarning) |
| 93 | + ModLoader.get().addWarning(new ModLoadingWarning(ModLoadingContext.get().getActiveContainer().getModInfo(), ModLoadingStage.COMMON_SETUP, "modernfix.perf_mod_warning")); |
84 | 94 | }); |
85 | 95 | } |
86 | 96 | ObjectHolderClearer.clearThrowables(); |
|
0 commit comments