Add ModCore integration
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
//#if FABRIC>=1
|
||||
package com.replaymod.core;
|
||||
|
||||
import com.replaymod.extras.modcore.ModCoreInstaller;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import org.spongepowered.asm.mixin.Mixins;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Optional;
|
||||
|
||||
// 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 {
|
||||
@@ -16,6 +22,41 @@ public class ReplayModMMLauncher implements Runnable {
|
||||
Mixins.addConfiguration("mixins.render.blend.replaymod.json");
|
||||
Mixins.addConfiguration("mixins.render.replaymod.json");
|
||||
Mixins.addConfiguration("mixins.replay.replaymod.json");
|
||||
|
||||
try {
|
||||
initModCore();
|
||||
} catch (Throwable t) {
|
||||
System.err.println("ReplayMod caught error during ModCore init:");
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Forge equivalent is in ReplayModTweaker
|
||||
private void initModCore() {
|
||||
if (System.getProperty("REPLAYMOD_SKIP_MODCORE", "false").equalsIgnoreCase("true")) {
|
||||
System.out.println("ReplayMod not initializing ModCore because REPLAYMOD_SKIP_MODCORE is true.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (FabricLoader.getInstance().isDevelopmentEnvironment()) {
|
||||
System.out.println("ReplayMod not initializing ModCore because we're in a development environment.");
|
||||
return;
|
||||
}
|
||||
|
||||
File gameDir = FabricLoader.getInstance().getGameDirectory();
|
||||
|
||||
Optional<ModContainer> minecraft = FabricLoader.getInstance().getModContainer("minecraft");
|
||||
if (!minecraft.isPresent()) {
|
||||
System.err.println("ReplayMod could not determine Minecraft version, skipping ModCore.");
|
||||
return;
|
||||
}
|
||||
String mcVer = minecraft.get().getMetadata().getVersion().getFriendlyString();
|
||||
|
||||
int result = ModCoreInstaller.initialize(gameDir, mcVer + "_fabric");
|
||||
System.out.println("ReplayMod ModCore init result: " + result);
|
||||
if (ModCoreInstaller.isErrored()) {
|
||||
System.err.println(ModCoreInstaller.getError());
|
||||
}
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
//#if FABRIC>=1
|
||||
// Fabric equivalent is in ReplayModMMLauncher
|
||||
//#else
|
||||
//#if MC>=11400
|
||||
//$$ // Generally not supported by RM
|
||||
//#else
|
||||
//$$ package com.replaymod.core.tweaker;
|
||||
//$$
|
||||
//$$ import com.replaymod.extras.modcore.ModCoreInstaller;
|
||||
//$$ import net.minecraft.launchwrapper.ITweaker;
|
||||
//$$ import net.minecraft.launchwrapper.Launch;
|
||||
//$$ import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
//$$
|
||||
//$$ import java.io.File;
|
||||
//$$ import java.util.List;
|
||||
//$$
|
||||
//$$ public class ReplayModTweaker implements ITweaker {
|
||||
//$$ @Override
|
||||
//$$ public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Override
|
||||
//$$ public void injectIntoClassLoader(LaunchClassLoader classLoader) {
|
||||
//$$ // Inject Mixin's tweaker (cause you can only specify one tweaker in the manifest)
|
||||
//$$ @SuppressWarnings("unchecked")
|
||||
//$$ List<String> tweakClasses = (List<String>) Launch.blackboard.get("TweakClasses");
|
||||
//$$ tweakClasses.add("org.spongepowered.asm.launch.MixinTweaker");
|
||||
//$$
|
||||
//#if MC>=11202 && MC<=11202
|
||||
//$$ initModCore("1.12.2");
|
||||
//#endif
|
||||
//#if MC>=10809 && MC<=10809
|
||||
//$$ initModCore("1.8.9");
|
||||
//#endif
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Override
|
||||
//$$ public String getLaunchTarget() {
|
||||
//$$ return null;
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Override
|
||||
//$$ public String[] getLaunchArguments() {
|
||||
//$$ return new String[0];
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ private void initModCore(String mcVer) {
|
||||
//$$ try {
|
||||
//$$ if (System.getProperty("REPLAYMOD_SKIP_MODCORE", "false").equalsIgnoreCase("true")) {
|
||||
//$$ System.out.println("ReplayMod not initializing ModCore because REPLAYMOD_SKIP_MODCORE is true.");
|
||||
//$$ return;
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ if ((Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment")) {
|
||||
//$$ System.out.println("ReplayMod not initializing ModCore because we're in a development environment.");
|
||||
//$$ return;
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ int result = ModCoreInstaller.initialize(Launch.minecraftHome, mcVer + "_forge");
|
||||
//$$ System.out.println("ReplayMod ModCore init result: " + result);
|
||||
//$$ if (ModCoreInstaller.isErrored()) {
|
||||
//$$ System.err.println(ModCoreInstaller.getError());
|
||||
//$$ }
|
||||
//$$ } catch (Throwable t) {
|
||||
//$$ System.err.println("ReplayMod caught error during ModCore init:");
|
||||
//$$ t.printStackTrace();
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#endif
|
||||
//#endif
|
||||
Reference in New Issue
Block a user