diff --git a/src/main/java/gripe/_90/appliede/AppliedE.java b/src/main/java/gripe/_90/appliede/AppliedE.java index 8299a4a..ef06125 100644 --- a/src/main/java/gripe/_90/appliede/AppliedE.java +++ b/src/main/java/gripe/_90/appliede/AppliedE.java @@ -17,6 +17,8 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLEnvironment; +import net.minecraftforge.fml.loading.LoadingModList; +import net.minecraftforge.fml.loading.moddiscovery.ModInfo; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; @@ -73,7 +75,7 @@ public final class AppliedE { ITEMS.register("emc_interface", () -> new BlockItem(block, new Item.Properties())); return block; }); - public static final RegistryObject CABLE_EMC_INTERFACE = ITEMS.register("cable_emc_interface", () -> ModList.get().isLoaded("aecapfix") + public static final RegistryObject CABLE_EMC_INTERFACE = ITEMS.register("cable_emc_interface", () -> isModLoaded("aecapfix") ? part(EMCInterfacePartAECF.class, EMCInterfacePartAECF::new) : part(EMCInterfacePart.class, EMCInterfacePart::new)); @@ -118,9 +120,15 @@ public static ResourceLocation id(String path) { return new ResourceLocation(MODID, path); } + private static boolean isModLoaded(String modId) { + return ModList.get() != null + ? ModList.get().isLoaded(modId) + : LoadingModList.get().getMods().stream().map(ModInfo::getModId).anyMatch(modId::equals); + } + public static boolean useCustomMapper() { // prioritise existing AE2 EMC mapping add-on over this one - if (ModList.get().isLoaded("projecteintegration")) { + if (isModLoaded("projecteintegration")) { return false; }