diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplat.java b/common/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplat.java index 13675de93..c1006ce63 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplat.java +++ b/common/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplat.java @@ -1,5 +1,7 @@ package dev.engine_room.flywheel.impl; +import java.util.function.Supplier; + import dev.engine_room.flywheel.api.internal.DependencyInjection; import net.minecraft.client.multiplayer.ClientLevel; @@ -11,4 +13,6 @@ public interface FlwImplXplat { String getVersionStr(); FlwConfig getConfig(); + + Supplier getModLoaded(String modId); } diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/compat/CompatMods.java b/common/src/main/java/dev/engine_room/flywheel/impl/compat/CompatMods.java index 612316dc3..4201aa98d 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/compat/CompatMods.java +++ b/common/src/main/java/dev/engine_room/flywheel/impl/compat/CompatMods.java @@ -2,18 +2,17 @@ package dev.engine_room.flywheel.impl.compat; import java.util.function.Supplier; -import com.google.common.base.Suppliers; - -import net.fabricmc.loader.api.FabricLoader; +import dev.engine_room.flywheel.impl.FlwImplXplat; public enum CompatMods { SODIUM, - EMBEDDIUM; + EMBEDDIUM, + IRIS; private final Supplier isLoaded; CompatMods() { - isLoaded = Suppliers.memoize(() -> FabricLoader.getInstance().isModLoaded(name())); + isLoaded = FlwImplXplat.INSTANCE.getModLoaded(name()); } public boolean isLoaded() { diff --git a/fabric/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java b/fabric/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java index 4bd60bd7d..56a725969 100644 --- a/fabric/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java +++ b/fabric/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java @@ -1,6 +1,11 @@ package dev.engine_room.flywheel.impl; +import java.util.function.Supplier; + +import com.google.common.base.Suppliers; + import dev.engine_room.flywheel.api.event.ReloadLevelRendererCallback; +import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.multiplayer.ClientLevel; public class FlwImplXplatImpl implements FlwImplXplat { @@ -18,4 +23,9 @@ public class FlwImplXplatImpl implements FlwImplXplat { public FlwConfig getConfig() { return FabricFlwConfig.INSTANCE; } + + @Override + public Supplier getModLoaded(String modId) { + return Suppliers.memoize(() -> FabricLoader.getInstance().isModLoaded(modId)); + } } diff --git a/fabric/src/main/java/dev/engine_room/flywheel/impl/FlwLibXplatImpl.java b/fabric/src/main/java/dev/engine_room/flywheel/impl/FlwLibXplatImpl.java index 897a7edd7..75194fed8 100644 --- a/fabric/src/main/java/dev/engine_room/flywheel/impl/FlwLibXplatImpl.java +++ b/fabric/src/main/java/dev/engine_room/flywheel/impl/FlwLibXplatImpl.java @@ -3,6 +3,7 @@ package dev.engine_room.flywheel.impl; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.UnknownNullability; +import dev.engine_room.flywheel.impl.compat.CompatMods; import dev.engine_room.flywheel.lib.internal.FlwLibXplat; import dev.engine_room.flywheel.lib.model.baked.BakedModelBuilder; import dev.engine_room.flywheel.lib.model.baked.BlockModelBuilder; @@ -11,7 +12,6 @@ import dev.engine_room.flywheel.lib.model.baked.FabricBlockModelBuilder; import dev.engine_room.flywheel.lib.model.baked.FabricMultiBlockModelBuilder; import dev.engine_room.flywheel.lib.model.baked.MultiBlockModelBuilder; import dev.engine_room.flywheel.lib.util.ShadersModHandler; -import net.fabricmc.loader.api.FabricLoader; import net.irisshaders.iris.api.v0.IrisApi; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.BlockRenderDispatcher; @@ -52,8 +52,7 @@ public class FlwLibXplatImpl implements FlwLibXplat { @Override @Nullable public ShadersModHandler.InternalHandler createIrisHandler() { - if (!FabricLoader.getInstance() - .isModLoaded("iris")) { + if (CompatMods.IRIS.isLoaded()) { return null; } diff --git a/forge/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java b/forge/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java index 2cc0dee9d..2a70b66a4 100644 --- a/forge/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java +++ b/forge/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java @@ -1,7 +1,12 @@ package dev.engine_room.flywheel.impl; +import java.util.function.Supplier; + +import com.google.common.base.Suppliers; + import dev.engine_room.flywheel.api.event.ReloadLevelRendererEvent; import net.minecraft.client.multiplayer.ClientLevel; +import net.neoforged.fml.loading.LoadingModList; import net.neoforged.neoforge.common.NeoForge; public class FlwImplXplatImpl implements FlwImplXplat { @@ -19,4 +24,9 @@ public class FlwImplXplatImpl implements FlwImplXplat { public FlwConfig getConfig() { return ForgeFlwConfig.INSTANCE; } + + @Override + public Supplier getModLoaded(String modId) { + return Suppliers.memoize(() -> LoadingModList.get().getModFileById(modId) != null); + } } diff --git a/forge/src/main/java/dev/engine_room/flywheel/impl/FlwLibXplatImpl.java b/forge/src/main/java/dev/engine_room/flywheel/impl/FlwLibXplatImpl.java index cf62e3d7e..098df8131 100644 --- a/forge/src/main/java/dev/engine_room/flywheel/impl/FlwLibXplatImpl.java +++ b/forge/src/main/java/dev/engine_room/flywheel/impl/FlwLibXplatImpl.java @@ -5,6 +5,7 @@ import java.lang.reflect.Field; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.UnknownNullability; +import dev.engine_room.flywheel.impl.compat.CompatMods; import dev.engine_room.flywheel.lib.internal.FlwLibXplat; import dev.engine_room.flywheel.lib.model.baked.BakedModelBuilder; import dev.engine_room.flywheel.lib.model.baked.BlockModelBuilder; @@ -24,7 +25,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.state.BlockState; -import net.neoforged.fml.ModList; import net.neoforged.fml.util.ObfuscationReflectionHelper; public class FlwLibXplatImpl implements FlwLibXplat { @@ -69,8 +69,7 @@ public class FlwLibXplatImpl implements FlwLibXplat { @Override @Nullable public ShadersModHandler.InternalHandler createIrisHandler() { - if (!ModList.get() - .isLoaded("iris")) { + if (!CompatMods.IRIS.isLoaded()) { return null; }