Fix issues

This commit is contained in:
IThundxr 2024-09-14 09:40:33 -04:00
parent fc61ff1c98
commit 3176f1d0f5
No known key found for this signature in database
GPG Key ID: E291EC97BAF935E6
6 changed files with 32 additions and 11 deletions

View File

@ -1,5 +1,7 @@
package dev.engine_room.flywheel.impl; package dev.engine_room.flywheel.impl;
import java.util.function.Supplier;
import dev.engine_room.flywheel.api.internal.DependencyInjection; import dev.engine_room.flywheel.api.internal.DependencyInjection;
import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientLevel;
@ -11,4 +13,6 @@ public interface FlwImplXplat {
String getVersionStr(); String getVersionStr();
FlwConfig getConfig(); FlwConfig getConfig();
Supplier<Boolean> getModLoaded(String modId);
} }

View File

@ -2,18 +2,17 @@ package dev.engine_room.flywheel.impl.compat;
import java.util.function.Supplier; import java.util.function.Supplier;
import com.google.common.base.Suppliers; import dev.engine_room.flywheel.impl.FlwImplXplat;
import net.fabricmc.loader.api.FabricLoader;
public enum CompatMods { public enum CompatMods {
SODIUM, SODIUM,
EMBEDDIUM; EMBEDDIUM,
IRIS;
private final Supplier<Boolean> isLoaded; private final Supplier<Boolean> isLoaded;
CompatMods() { CompatMods() {
isLoaded = Suppliers.memoize(() -> FabricLoader.getInstance().isModLoaded(name())); isLoaded = FlwImplXplat.INSTANCE.getModLoaded(name());
} }
public boolean isLoaded() { public boolean isLoaded() {

View File

@ -1,6 +1,11 @@
package dev.engine_room.flywheel.impl; 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 dev.engine_room.flywheel.api.event.ReloadLevelRendererCallback;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientLevel;
public class FlwImplXplatImpl implements FlwImplXplat { public class FlwImplXplatImpl implements FlwImplXplat {
@ -18,4 +23,9 @@ public class FlwImplXplatImpl implements FlwImplXplat {
public FlwConfig getConfig() { public FlwConfig getConfig() {
return FabricFlwConfig.INSTANCE; return FabricFlwConfig.INSTANCE;
} }
@Override
public Supplier<Boolean> getModLoaded(String modId) {
return Suppliers.memoize(() -> FabricLoader.getInstance().isModLoaded(modId));
}
} }

View File

@ -3,6 +3,7 @@ package dev.engine_room.flywheel.impl;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability; 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.internal.FlwLibXplat;
import dev.engine_room.flywheel.lib.model.baked.BakedModelBuilder; import dev.engine_room.flywheel.lib.model.baked.BakedModelBuilder;
import dev.engine_room.flywheel.lib.model.baked.BlockModelBuilder; 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.FabricMultiBlockModelBuilder;
import dev.engine_room.flywheel.lib.model.baked.MultiBlockModelBuilder; import dev.engine_room.flywheel.lib.model.baked.MultiBlockModelBuilder;
import dev.engine_room.flywheel.lib.util.ShadersModHandler; import dev.engine_room.flywheel.lib.util.ShadersModHandler;
import net.fabricmc.loader.api.FabricLoader;
import net.irisshaders.iris.api.v0.IrisApi; import net.irisshaders.iris.api.v0.IrisApi;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.BlockRenderDispatcher; import net.minecraft.client.renderer.block.BlockRenderDispatcher;
@ -52,8 +52,7 @@ public class FlwLibXplatImpl implements FlwLibXplat {
@Override @Override
@Nullable @Nullable
public ShadersModHandler.InternalHandler createIrisHandler() { public ShadersModHandler.InternalHandler createIrisHandler() {
if (!FabricLoader.getInstance() if (CompatMods.IRIS.isLoaded()) {
.isModLoaded("iris")) {
return null; return null;
} }

View File

@ -1,7 +1,12 @@
package dev.engine_room.flywheel.impl; 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 dev.engine_room.flywheel.api.event.ReloadLevelRendererEvent;
import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientLevel;
import net.neoforged.fml.loading.LoadingModList;
import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.common.NeoForge;
public class FlwImplXplatImpl implements FlwImplXplat { public class FlwImplXplatImpl implements FlwImplXplat {
@ -19,4 +24,9 @@ public class FlwImplXplatImpl implements FlwImplXplat {
public FlwConfig getConfig() { public FlwConfig getConfig() {
return ForgeFlwConfig.INSTANCE; return ForgeFlwConfig.INSTANCE;
} }
@Override
public Supplier<Boolean> getModLoaded(String modId) {
return Suppliers.memoize(() -> LoadingModList.get().getModFileById(modId) != null);
}
} }

View File

@ -5,6 +5,7 @@ import java.lang.reflect.Field;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability; 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.internal.FlwLibXplat;
import dev.engine_room.flywheel.lib.model.baked.BakedModelBuilder; import dev.engine_room.flywheel.lib.model.baked.BakedModelBuilder;
import dev.engine_room.flywheel.lib.model.baked.BlockModelBuilder; 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.resources.ResourceLocation;
import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.fml.ModList;
import net.neoforged.fml.util.ObfuscationReflectionHelper; import net.neoforged.fml.util.ObfuscationReflectionHelper;
public class FlwLibXplatImpl implements FlwLibXplat { public class FlwLibXplatImpl implements FlwLibXplat {
@ -69,8 +69,7 @@ public class FlwLibXplatImpl implements FlwLibXplat {
@Override @Override
@Nullable @Nullable
public ShadersModHandler.InternalHandler createIrisHandler() { public ShadersModHandler.InternalHandler createIrisHandler() {
if (!ModList.get() if (!CompatMods.IRIS.isLoaded()) {
.isLoaded("iris")) {
return null; return null;
} }