Skip to content

Commit

Permalink
started work changing from expect platform to java services
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Jun 13, 2024
1 parent 51b30d2 commit 708babf
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public static void onRegistration(RegistrationEvent event) {
}

public static boolean isModLoaded(String mod) {
return AntimatterPreLaunchUtil.isModLoaded(mod);
return AntimatterPreLaunchUtil.INSTANCE.isModLoaded(mod);
}

public static void runOnEvent(RegistrationEvent event, Runnable runnable) {
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 AntimatterPreLaunchUtil.isModLoaded(Ref.MOD_REI);
return AntimatterPreLaunchUtil.INSTANCE.isModLoaded(Ref.MOD_REI);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package muramasa.antimatter.util;

import dev.architectury.injectables.annotations.ExpectPlatform;
import tesseract.TesseractCapUtils;

public class AntimatterPreLaunchUtil {
@ExpectPlatform
public static boolean isModLoaded(String modid){
throw new AssertionError();
}
import java.util.ServiceLoader;

public interface AntimatterPreLaunchUtil {
AntimatterPreLaunchUtil INSTANCE = ServiceLoader.load(AntimatterPreLaunchUtil.class).findFirst().orElseThrow(() -> new IllegalStateException("No implementation of AntimatterPreLaunchUtil found"));
boolean isModLoaded(String modid);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package muramasa.antimatter.util.fabric;

import muramasa.antimatter.util.AntimatterPreLaunchUtil;
import net.fabricmc.loader.api.FabricLoader;

public class AntimatterPreLaunchUtilImpl {
public static boolean isModLoaded(String modid){
public class AntimatterPreLaunchUtilImpl implements AntimatterPreLaunchUtil {
@Override
public boolean isModLoaded(String modid){
return FabricLoader.getInstance().isModLoaded(modid);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
muramasa.antimatter.util.fabric.AntimatterPreLaunchUtilImpl
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package muramasa.antimatter.util.forge;

import muramasa.antimatter.util.AntimatterPreLaunchUtil;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.loading.LoadingModList;
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;

public class AntimatterPreLaunchUtilImpl {
public static boolean isModLoaded(String modid){
public class AntimatterPreLaunchUtilImpl implements AntimatterPreLaunchUtil {
@Override
public boolean isModLoaded(String modid){
if (ModList.get() == null) {
return LoadingModList.get().getMods().stream().map(ModInfo::getModId).anyMatch(modid::equals);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
muramasa.antimatter.util.forge.AntimatterPreLaunchUtilImpl

0 comments on commit 708babf

Please sign in to comment.