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 94232f7 commit ad4c012
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 37 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,23 +1,17 @@
package dev.engine_room.flywheel.impl.compat;

import java.util.function.BooleanSupplier;

import dev.engine_room.flywheel.impl.FlwImplXplat;

public enum CompatMods {
SODIUM("sodium"),
RUBIDIUM("rubidium"),
EMBEDDIUM("embeddium"),
IRIS("iris"),
OCULUS("oculus");

private final BooleanSupplier isLoaded;
OCULUS("oculus"),
RUBIDIUM("rubidium"),
SODIUM("sodium");

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 @@ -30,7 +30,7 @@ abstract class BlockEntityTypeMixin<T extends BlockEntity> implements BlockEntit

@Override
public void flywheel$setVisualizer(@Nullable BlockEntityVisualizer<? super T> visualizer) {
if (CompatMods.SODIUM.isLoaded() && !CompatMods.EMBEDDIUM.isLoaded() && SodiumCompatHelper.IS_SODIUM_0_6) {
if (CompatMods.SODIUM.isLoaded && !CompatMods.EMBEDDIUM.isLoaded && SodiumCompatHelper.IS_SODIUM_0_6) {
if (flywheel$visualizer == null && visualizer != null) {
flywheel$sodiumPredicate = SodiumCompat.addPredicate((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
Expand Up @@ -8,7 +8,7 @@

public class FabricSodiumCompatHelper {
public static void init() {
if (CompatMods.SODIUM.isLoaded() && !CompatMods.EMBEDDIUM.isLoaded()) {
if (CompatMods.SODIUM.isLoaded && !CompatMods.EMBEDDIUM.isLoaded) {
FabricLoader.getInstance().getModContainer("sodium").ifPresent(c -> {
Version sodiumVersion = c.getMetadata().getVersion();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public String getRefMapperConfig() {

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return CompatMods.SODIUM.isLoaded() && SodiumCompatHelper.IS_SODIUM_0_5;
return CompatMods.SODIUM.isLoaded && SodiumCompatHelper.IS_SODIUM_0_5;
}

@Override
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.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.loading.LoadingModList;

public class FlwImplXplatImpl implements FlwImplXplat {
@Override
public boolean getModLoaded(String modId) {
return LoadingModList.get().getModFileById(modId) != null;
}

@Override
public void dispatchReloadLevelRendererEvent(ClientLevel level) {
MinecraftForge.EVENT_BUS.post(new ReloadLevelRendererEvent(level));
Expand All @@ -22,9 +25,4 @@ public String getVersionStr() {
public FlwConfig getConfig() {
return ForgeFlwConfig.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 @@ -68,7 +68,7 @@ public MultiBlockModelBuilder createMultiBlockModelBuilder(BlockAndTintGetter le
@Override
@Nullable
public ShadersModHandler.InternalHandler createIrisHandler() {
if (!(CompatMods.IRIS.isLoaded() || CompatMods.OCULUS.isLoaded())) {
if (!(CompatMods.IRIS.isLoaded || CompatMods.OCULUS.isLoaded)) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private static void clientInit(IEventBus forgeEventBus, IEventBus modEventBus) {
CrashReportCallables.registerCrashCallable("Flywheel Backend", BackendManagerImpl::getBackendString);
FlwImpl.init();

if (CompatMods.EMBEDDIUM.isLoaded()) {
if (CompatMods.EMBEDDIUM.isLoaded) {
EmbeddiumCompat.init();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public class ForgeSodiumCompatHelper {
public static void init() {
if (CompatMods.SODIUM.isLoaded() && !(CompatMods.RUBIDIUM.isLoaded() && CompatMods.EMBEDDIUM.isLoaded())) {
if (CompatMods.SODIUM.isLoaded && !(CompatMods.RUBIDIUM.isLoaded && CompatMods.EMBEDDIUM.isLoaded)) {
SodiumCompatHelper.IS_SODIUM_0_6 = true;
}
}
Expand Down

0 comments on commit ad4c012

Please sign in to comment.