Skip to content

Commit

Permalink
address requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Oct 14, 2024
1 parent fa57f34 commit c705fdf
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package dev.engine_room.flywheel.impl;

import java.util.function.BooleanSupplier;

import dev.engine_room.flywheel.api.internal.DependencyInjection;
import net.minecraft.client.multiplayer.ClientLevel;

public interface FlwImplXplat {
FlwImplXplat INSTANCE = DependencyInjection.load(FlwImplXplat.class, "dev.engine_room.flywheel.impl.FlwImplXplatImpl");

boolean getModLoaded(String modId);

void dispatchReloadLevelRendererEvent(ClientLevel level);

String getVersionStr();

FlwConfig getConfig();

BooleanSupplier getModLoaded(String modId);
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
package dev.engine_room.flywheel.impl.compat;

import java.util.function.BooleanSupplier;

import dev.engine_room.flywheel.impl.FlwImplXplat;

public enum CompatMods {
SODIUM("sodium"),
IRIS("iris");

private final BooleanSupplier isLoaded;

CompatMods(String modid) {
isLoaded = FlwImplXplat.INSTANCE.getModLoaded(modid);
}
public final boolean isLoaded;

public boolean isLoaded() {
return isLoaded.getAsBoolean();
CompatMods(String modId) {
isLoaded = FlwImplXplat.INSTANCE.getModLoaded(modId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class BlockEntityTypeMixin<T extends BlockEntity> implements BlockEntit

@Override
public void flywheel$setVisualizer(@Nullable BlockEntityVisualizer<? super T> visualizer) {
if (CompatMods.SODIUM.isLoaded()) {
if (CompatMods.SODIUM.isLoaded) {
if (flywheel$visualizer == null && visualizer != null) {
flywheel$sodiumPredicate = SodiumCompat.forBlockEntityType((BlockEntityType<?>) (Object) this);
} else if (flywheel$visualizer != null && visualizer == null && flywheel$sodiumPredicate != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package dev.engine_room.flywheel.impl;

import java.util.function.BooleanSupplier;

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 {
@Override
public boolean getModLoaded(String modId) {
return FabricLoader.getInstance().isModLoaded(modId);
}

@Override
public void dispatchReloadLevelRendererEvent(ClientLevel level) {
ReloadLevelRendererCallback.EVENT.invoker().onReloadLevelRenderer(level);
Expand All @@ -21,9 +24,4 @@ public String getVersionStr() {
public FlwConfig getConfig() {
return FabricFlwConfig.INSTANCE;
}

@Override
public BooleanSupplier getModLoaded(String modId) {
return () -> FabricLoader.getInstance().isModLoaded(modId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public MultiBlockModelBuilder createMultiBlockModelBuilder(BlockAndTintGetter le
@Override
@Nullable
public ShadersModHandler.InternalHandler createIrisHandler() {
if (!CompatMods.IRIS.isLoaded()) {
if (!CompatMods.IRIS.isLoaded) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package dev.engine_room.flywheel.impl;

import java.util.function.BooleanSupplier;

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 {
@Override
public boolean getModLoaded(String modId) {
return LoadingModList.get().getModFileById(modId) != null;
}

@Override
public void dispatchReloadLevelRendererEvent(ClientLevel level) {
NeoForge.EVENT_BUS.post(new ReloadLevelRendererEvent(level));
Expand All @@ -22,9 +25,4 @@ public String getVersionStr() {
public FlwConfig getConfig() {
return NeoForgeFlwConfig.INSTANCE;
}

@Override
public BooleanSupplier getModLoaded(String modId) {
return () -> LoadingModList.get().getModFileById(modId) != null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

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.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;
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.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 net.irisshaders.iris.api.v0.IrisApi;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -70,7 +69,7 @@ public MultiBlockModelBuilder createMultiBlockModelBuilder(BlockAndTintGetter le
@Override
@Nullable
public ShadersModHandler.InternalHandler createIrisHandler() {
if (!CompatMods.IRIS.isLoaded()) {
if (!CompatMods.IRIS.isLoaded) {
return null;
}

Expand Down

0 comments on commit c705fdf

Please sign in to comment.