address requested changes

This commit is contained in:
IThundxr 2024-10-14 18:06:34 -04:00
parent fa57f34c47
commit c705fdfc6f
Failed to generate hash of commit
7 changed files with 21 additions and 34 deletions

View file

@ -1,18 +1,16 @@
package dev.engine_room.flywheel.impl; package dev.engine_room.flywheel.impl;
import java.util.function.BooleanSupplier;
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;
public interface FlwImplXplat { public interface FlwImplXplat {
FlwImplXplat INSTANCE = DependencyInjection.load(FlwImplXplat.class, "dev.engine_room.flywheel.impl.FlwImplXplatImpl"); FlwImplXplat INSTANCE = DependencyInjection.load(FlwImplXplat.class, "dev.engine_room.flywheel.impl.FlwImplXplatImpl");
boolean getModLoaded(String modId);
void dispatchReloadLevelRendererEvent(ClientLevel level); void dispatchReloadLevelRendererEvent(ClientLevel level);
String getVersionStr(); String getVersionStr();
FlwConfig getConfig(); FlwConfig getConfig();
BooleanSupplier getModLoaded(String modId);
} }

View file

@ -1,20 +1,14 @@
package dev.engine_room.flywheel.impl.compat; package dev.engine_room.flywheel.impl.compat;
import java.util.function.BooleanSupplier;
import dev.engine_room.flywheel.impl.FlwImplXplat; import dev.engine_room.flywheel.impl.FlwImplXplat;
public enum CompatMods { public enum CompatMods {
SODIUM("sodium"), SODIUM("sodium"),
IRIS("iris"); IRIS("iris");
private final BooleanSupplier isLoaded; public final boolean isLoaded;
CompatMods(String modid) { CompatMods(String modId) {
isLoaded = FlwImplXplat.INSTANCE.getModLoaded(modid); isLoaded = FlwImplXplat.INSTANCE.getModLoaded(modId);
}
public boolean isLoaded() {
return isLoaded.getAsBoolean();
} }
} }

View file

@ -29,7 +29,7 @@ abstract class BlockEntityTypeMixin<T extends BlockEntity> implements BlockEntit
@Override @Override
public void flywheel$setVisualizer(@Nullable BlockEntityVisualizer<? super T> visualizer) { public void flywheel$setVisualizer(@Nullable BlockEntityVisualizer<? super T> visualizer) {
if (CompatMods.SODIUM.isLoaded()) { if (CompatMods.SODIUM.isLoaded) {
if (flywheel$visualizer == null && visualizer != null) { if (flywheel$visualizer == null && visualizer != null) {
flywheel$sodiumPredicate = SodiumCompat.forBlockEntityType((BlockEntityType<?>) (Object) this); flywheel$sodiumPredicate = SodiumCompat.forBlockEntityType((BlockEntityType<?>) (Object) this);
} else if (flywheel$visualizer != null && visualizer == null && flywheel$sodiumPredicate != null) { } else if (flywheel$visualizer != null && visualizer == null && flywheel$sodiumPredicate != null) {

View file

@ -1,12 +1,15 @@
package dev.engine_room.flywheel.impl; package dev.engine_room.flywheel.impl;
import java.util.function.BooleanSupplier;
import dev.engine_room.flywheel.api.event.ReloadLevelRendererCallback; import dev.engine_room.flywheel.api.event.ReloadLevelRendererCallback;
import net.fabricmc.loader.api.FabricLoader; 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 {
@Override
public boolean getModLoaded(String modId) {
return FabricLoader.getInstance().isModLoaded(modId);
}
@Override @Override
public void dispatchReloadLevelRendererEvent(ClientLevel level) { public void dispatchReloadLevelRendererEvent(ClientLevel level) {
ReloadLevelRendererCallback.EVENT.invoker().onReloadLevelRenderer(level); ReloadLevelRendererCallback.EVENT.invoker().onReloadLevelRenderer(level);
@ -21,9 +24,4 @@ public class FlwImplXplatImpl implements FlwImplXplat {
public FlwConfig getConfig() { public FlwConfig getConfig() {
return FabricFlwConfig.INSTANCE; return FabricFlwConfig.INSTANCE;
} }
@Override
public BooleanSupplier getModLoaded(String modId) {
return () -> FabricLoader.getInstance().isModLoaded(modId);
}
} }

View file

@ -52,7 +52,7 @@ public class FlwLibXplatImpl implements FlwLibXplat {
@Override @Override
@Nullable @Nullable
public ShadersModHandler.InternalHandler createIrisHandler() { public ShadersModHandler.InternalHandler createIrisHandler() {
if (!CompatMods.IRIS.isLoaded()) { if (!CompatMods.IRIS.isLoaded) {
return null; return null;
} }

View file

@ -1,13 +1,16 @@
package dev.engine_room.flywheel.impl; package dev.engine_room.flywheel.impl;
import java.util.function.BooleanSupplier;
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.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 {
@Override
public boolean getModLoaded(String modId) {
return LoadingModList.get().getModFileById(modId) != null;
}
@Override @Override
public void dispatchReloadLevelRendererEvent(ClientLevel level) { public void dispatchReloadLevelRendererEvent(ClientLevel level) {
NeoForge.EVENT_BUS.post(new ReloadLevelRendererEvent(level)); NeoForge.EVENT_BUS.post(new ReloadLevelRendererEvent(level));
@ -22,9 +25,4 @@ public class FlwImplXplatImpl implements FlwImplXplat {
public FlwConfig getConfig() { public FlwConfig getConfig() {
return NeoForgeFlwConfig.INSTANCE; return NeoForgeFlwConfig.INSTANCE;
} }
@Override
public BooleanSupplier getModLoaded(String modId) {
return () -> LoadingModList.get().getModFileById(modId) != null;
}
} }

View file

@ -2,9 +2,6 @@ package dev.engine_room.flywheel.impl;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import dev.engine_room.flywheel.lib.model.baked.NeoForgeBlockModelBuilder;
import dev.engine_room.flywheel.lib.model.baked.NeoForgeMultiBlockModelBuilder;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability; import org.jetbrains.annotations.UnknownNullability;
@ -12,8 +9,10 @@ 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;
import dev.engine_room.flywheel.lib.model.baked.NeoForgeBakedModelBuilder;
import dev.engine_room.flywheel.lib.model.baked.MultiBlockModelBuilder; import dev.engine_room.flywheel.lib.model.baked.MultiBlockModelBuilder;
import dev.engine_room.flywheel.lib.model.baked.NeoForgeBakedModelBuilder;
import dev.engine_room.flywheel.lib.model.baked.NeoForgeBlockModelBuilder;
import dev.engine_room.flywheel.lib.model.baked.NeoForgeMultiBlockModelBuilder;
import dev.engine_room.flywheel.lib.util.ShadersModHandler; import dev.engine_room.flywheel.lib.util.ShadersModHandler;
import net.irisshaders.iris.api.v0.IrisApi; import net.irisshaders.iris.api.v0.IrisApi;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -70,7 +69,7 @@ public class FlwLibXplatImpl implements FlwLibXplat {
@Override @Override
@Nullable @Nullable
public ShadersModHandler.InternalHandler createIrisHandler() { public ShadersModHandler.InternalHandler createIrisHandler() {
if (!CompatMods.IRIS.isLoaded()) { if (!CompatMods.IRIS.isLoaded) {
return null; return null;
} }