diff --git a/common/src/main/java/malte0811/ferritecore/mixin/config/FerriteMixinConfig.java b/common/src/main/java/malte0811/ferritecore/mixin/config/FerriteMixinConfig.java index 490b8d6..6f9f1e6 100644 --- a/common/src/main/java/malte0811/ferritecore/mixin/config/FerriteMixinConfig.java +++ b/common/src/main/java/malte0811/ferritecore/mixin/config/FerriteMixinConfig.java @@ -15,31 +15,23 @@ public abstract class FerriteMixinConfig implements IMixinConfigPlugin { protected static final Logger LOGGER = LogManager.getLogger("ferritecore-mixin"); private static final boolean HAS_LITHIUM; + private static final boolean HAS_ROADRUNNER; static { - boolean hasLithium; - try { - // This does *not* load the class! - MixinService.getService() - .getBytecodeProvider() - .getClassNode("me.jellysquid.mods.lithium.common.LithiumMod"); - hasLithium = true; - } catch (ClassNotFoundException | IOException e) { - hasLithium = false; - } - HAS_LITHIUM = hasLithium; + HAS_LITHIUM = hasClass("me.jellysquid.mods.lithium.common.LithiumMod"); + HAS_ROADRUNNER = hasClass("me.jellysquid.mods.lithium.common.RoadRunner"); } private String prefix = null; private final FerriteConfig.Option enableOption; - private final boolean disableWithLithium; + private final LithiumSupportState lithiumState; - protected FerriteMixinConfig(FerriteConfig.Option enableOption, boolean disableWithLithium) { + protected FerriteMixinConfig(FerriteConfig.Option enableOption, LithiumSupportState lithiumCompat) { this.enableOption = enableOption; - this.disableWithLithium = disableWithLithium; + this.lithiumState = lithiumCompat; } protected FerriteMixinConfig(FerriteConfig.Option enableOption) { - this(enableOption, false); + this(enableOption, LithiumSupportState.NO_CONFLICT); } @Override @@ -48,7 +40,7 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { if (!enableOption.isEnabled()) { LOGGER.warn("Mixin " + mixinClassName + " is disabled by config"); return false; - } else if (disableWithLithium && HAS_LITHIUM) { + } else if (!this.lithiumState.shouldApply()) { LOGGER.warn("Mixin " + mixinClassName + " is disabled automatically as lithium is installed"); return false; } else { @@ -75,4 +67,28 @@ public void preApply(String targetClassName, ClassNode targetClass, String mixin @Override public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {} + + private static boolean hasClass(String name) { + try { + // This does *not* load the class! + MixinService.getService().getBytecodeProvider().getClassNode(name); + return true; + } catch (ClassNotFoundException | IOException e) { + return false; + } + } + + protected enum LithiumSupportState { + NO_CONFLICT, + INCOMPATIBLE, + APPLY_IF_ROADRUNNER; + + private boolean shouldApply() { + return switch (this) { + case NO_CONFLICT -> true; + case INCOMPATIBLE -> !HAS_LITHIUM; + case APPLY_IF_ROADRUNNER -> !HAS_LITHIUM || HAS_ROADRUNNER; + }; + } + } } diff --git a/common/src/main/java/malte0811/ferritecore/mixin/threaddetec/Config.java b/common/src/main/java/malte0811/ferritecore/mixin/threaddetec/Config.java index cc576ff..ed7c169 100644 --- a/common/src/main/java/malte0811/ferritecore/mixin/threaddetec/Config.java +++ b/common/src/main/java/malte0811/ferritecore/mixin/threaddetec/Config.java @@ -5,6 +5,6 @@ public class Config extends FerriteMixinConfig { public Config() { - super(FerriteConfig.THREADING_DETECTOR, true); + super(FerriteConfig.THREADING_DETECTOR, LithiumSupportState.APPLY_IF_ROADRUNNER); } } diff --git a/forge/src/main/resources/roadrunner.overrides.properties b/forge/src/main/resources/roadrunner.overrides.properties new file mode 100644 index 0000000..8fdd1ea --- /dev/null +++ b/forge/src/main/resources/roadrunner.overrides.properties @@ -0,0 +1 @@ +mixin.alloc.blockstate = false