Skip to content

Commit

Permalink
Fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Sep 14, 2024
1 parent fc61ff1 commit 3176f1d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -11,4 +13,6 @@ public interface FlwImplXplat {
String getVersionStr();

FlwConfig getConfig();

Supplier<Boolean> getModLoaded(String modId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

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<Boolean> isLoaded;

CompatMods() {
isLoaded = Suppliers.memoize(() -> FabricLoader.getInstance().isModLoaded(name()));
isLoaded = FlwImplXplat.INSTANCE.getModLoaded(name());
}

public boolean isLoaded() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -18,4 +23,9 @@ public String getVersionStr() {
public FlwConfig getConfig() {
return FabricFlwConfig.INSTANCE;
}

@Override
public Supplier<Boolean> getModLoaded(String modId) {
return Suppliers.memoize(() -> FabricLoader.getInstance().isModLoaded(modId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;
Expand All @@ -11,7 +12,6 @@
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;
Expand Down Expand Up @@ -52,8 +52,7 @@ public MultiBlockModelBuilder createMultiBlockModelBuilder(BlockAndTintGetter le
@Override
@Nullable
public ShadersModHandler.InternalHandler createIrisHandler() {
if (!FabricLoader.getInstance()
.isModLoaded("iris")) {
if (CompatMods.IRIS.isLoaded()) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -19,4 +24,9 @@ public String getVersionStr() {
public FlwConfig getConfig() {
return ForgeFlwConfig.INSTANCE;
}

@Override
public Supplier<Boolean> getModLoaded(String modId) {
return Suppliers.memoize(() -> LoadingModList.get().getModFileById(modId) != null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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;
Expand All @@ -24,7 +25,6 @@
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 {
Expand Down Expand Up @@ -69,8 +69,7 @@ public MultiBlockModelBuilder createMultiBlockModelBuilder(BlockAndTintGetter le
@Override
@Nullable
public ShadersModHandler.InternalHandler createIrisHandler() {
if (!ModList.get()
.isLoaded("iris")) {
if (!CompatMods.IRIS.isLoaded()) {
return null;
}

Expand Down

0 comments on commit 3176f1d

Please sign in to comment.