Work around the fact that our mixins may be loaded before Optifabric
This commit is contained in:
21
src/main/java/com/replaymod/core/ReplayModMMLauncher.java
Normal file
21
src/main/java/com/replaymod/core/ReplayModMMLauncher.java
Normal file
@@ -0,0 +1,21 @@
|
||||
//#if FABRIC>=1
|
||||
package com.replaymod.core;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixins;
|
||||
|
||||
// We need to wait for MM to call us, otherwise we might initialize our mixins before it calls optifabric which would
|
||||
// result in OF classes not existing while our mixins get resolved.
|
||||
public class ReplayModMMLauncher implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
Mixins.addConfiguration("mixins.compat.mapwriter.replaymod.json");
|
||||
Mixins.addConfiguration("mixins.compat.shaders.replaymod.json");
|
||||
Mixins.addConfiguration("mixins.core.replaymod.json");
|
||||
Mixins.addConfiguration("mixins.extras.playeroverview.replaymod.json");
|
||||
Mixins.addConfiguration("mixins.recording.replaymod.json");
|
||||
Mixins.addConfiguration("mixins.render.blend.replaymod.json");
|
||||
Mixins.addConfiguration("mixins.render.replaymod.json");
|
||||
Mixins.addConfiguration("mixins.replay.replaymod.json");
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
62
src/main/java/com/replaymod/core/ReplayModNonMMLauncher.java
Normal file
62
src/main/java/com/replaymod/core/ReplayModNonMMLauncher.java
Normal file
@@ -0,0 +1,62 @@
|
||||
//#if FABRIC>=1
|
||||
package com.replaymod.core;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
// See ReplayModMMLauncher. This is the fallback if MM is not installed.
|
||||
public class ReplayModNonMMLauncher implements IMixinConfigPlugin {
|
||||
private final Logger logger = LogManager.getLogger("replaymod/nonmm");
|
||||
|
||||
@Override
|
||||
public void onLoad(String mixinPackage) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRefMapperConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMixins() {
|
||||
try {
|
||||
if (ReplayModMixinConfigPlugin.hasClass("com.chocohead.mm.Plugin")) {
|
||||
logger.info("Detected MM, they should call us...");
|
||||
} else {
|
||||
logger.info("Did not detect MM, initializing ourselves...");
|
||||
new ReplayModMMLauncher().run();
|
||||
}
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
@@ -24,17 +24,14 @@
|
||||
],
|
||||
"modmenu": [
|
||||
"com.replaymod.core.gui.ModMenuApiImpl"
|
||||
],
|
||||
"mm:early_risers": [
|
||||
"com.replaymod.core.ReplayModMMLauncher"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"mixins.jgui.json",
|
||||
"mixins.core.replaymod.json",
|
||||
"mixins.compat.shaders.replaymod.json",
|
||||
"mixins.extras.playeroverview.replaymod.json",
|
||||
"mixins.recording.replaymod.json",
|
||||
"mixins.render.blend.replaymod.json",
|
||||
"mixins.render.replaymod.json",
|
||||
"mixins.replay.replaymod.json"
|
||||
"mixins.nonmmlauncher.replaymod.json"
|
||||
],
|
||||
|
||||
"requires": {
|
||||
|
||||
11
src/main/resources/mixins.nonmmlauncher.replaymod.json
Normal file
11
src/main/resources/mixins.nonmmlauncher.replaymod.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "com.replaymod.mmdummy",
|
||||
"plugin": "com.replaymod.core.ReplayModNonMMLauncher",
|
||||
"mixins": [],
|
||||
"server": [],
|
||||
"client": [],
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"minVersion": "0.6.11",
|
||||
"refmap": "mixins.nonmmlauncher.replaymod.refmap.json"
|
||||
}
|
||||
Reference in New Issue
Block a user