Skip to content

Commit

Permalink
Cover the case in which integration mods need to be found while loading
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Apr 30, 2024
1 parent 7a83121 commit 09eabd7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/gripe/_90/appliede/AppliedE.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -73,7 +75,7 @@ public final class AppliedE {
ITEMS.register("emc_interface", () -> new BlockItem(block, new Item.Properties()));
return block;
});
public static final RegistryObject<Item> CABLE_EMC_INTERFACE = ITEMS.register("cable_emc_interface", () -> ModList.get().isLoaded("aecapfix")
public static final RegistryObject<Item> CABLE_EMC_INTERFACE = ITEMS.register("cable_emc_interface", () -> isModLoaded("aecapfix")
? part(EMCInterfacePartAECF.class, EMCInterfacePartAECF::new)
: part(EMCInterfacePart.class, EMCInterfacePart::new));

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 09eabd7

Please sign in to comment.