Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

Commit

Permalink
update patch
Browse files Browse the repository at this point in the history
  • Loading branch information
wohaopa committed Feb 8, 2023
1 parent 8f815a1 commit 6a9ab0b
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ReplayModFixMod
EN
[](https://github.com/wohaopa/ReplayModFixMod/README_CN.md)
[](https://github.com/wohaopa/ReplayModFixMod/blob/master/README_CN.md)

**The following content is translated by machine**

Expand All @@ -16,6 +16,6 @@ Used to fix mods where ReplayMod does not work in GTNH. Because ReplayMod is so
## Description
If you have any problems using ReplayMod in GTNH, please give feedback in this project.
## How to use
Download ReplayMod 2.5.2. Use compression software to open, replace `com\replaymod\core\tweaker\ReplayModTweaker.class` with [ReplayModTweaker.class](https://github.com/wohaopa/ReplayModFixMod/replace/ReplayModTweaker.class) and put this mod and replaymod in the mods folder. Download and install directories [ffmpeg](https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-5.1.2-essentials_build.zip) through `.minecraft`.
Download ReplayMod 2.5.2. Use compression software to open, replace `com\replaymod\core\tweaker\ReplayModTweaker.class` with [ReplayModTweaker.class](https://github.com/wohaopa/ReplayModFixMod/blob/master/replace/ReplayModTweaker.class) and put this mod and replaymod in the mods folder. Download and install directories [ffmpeg](https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-5.1.2-essentials_build.zip) through `.minecraft`.


2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
## 说明
在GTNH中使用ReplayMod遇到问题请在本项目中反馈。
## 使用方法
下载ReplayMod 2.5.2版本。使用压缩软件打开,替换`com\replaymod\core\tweaker\ReplayModTweaker.class`[ReplayModTweaker.class](https://github.com/wohaopa/ReplayModFixMod/replace/ReplayModTweaker.class) 将本mod与replaymod一并放入至mods文件夹。下载并安装[ffmpeg](https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-5.1.2-essentials_build.zip)`.minecraft`目录即可。
下载ReplayMod 2.5.2版本。使用压缩软件打开,替换`com\replaymod\core\tweaker\ReplayModTweaker.class`[ReplayModTweaker.class](https://github.com/wohaopa/ReplayModFixMod/blob/master/replace/ReplayModTweaker.class) 将本mod与replaymod一并放入至mods文件夹。下载并安装[ffmpeg](https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-5.1.2-essentials_build.zip)`.minecraft`目录即可。
Binary file added replace/ReplayModTweaker.class
Binary file not shown.
80 changes: 80 additions & 0 deletions replace/ReplayModTweaker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.replaymod.core.tweaker;

import com.replaymod.extras.modcore.ModCoreInstaller;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import net.minecraft.launchwrapper.ITweaker;
import net.minecraft.launchwrapper.Launch;
import net.minecraft.launchwrapper.LaunchClassLoader;
import org.spongepowered.asm.launch.GlobalProperties;
import org.spongepowered.asm.launch.MixinBootstrap;
import org.spongepowered.asm.launch.platform.MixinPlatformManager;
import org.spongepowered.asm.launch.platform.container.ContainerHandleURI;

public class ReplayModTweaker implements ITweaker {
private static final String MIXIN_TWEAKER = "org.spongepowered.asm.launch.MixinTweaker";

public ReplayModTweaker() {
injectMixinTweaker();
}

private void injectMixinTweaker() {
List<String> tweakClasses = (List<String>)Launch.blackboard.get("TweakClasses");
if (tweakClasses.contains("org.spongepowered.asm.launch.MixinTweaker"))
return;
if (GlobalProperties.get(GlobalProperties.Keys.INIT) != null)
return;
System.out.println("Injecting MixinTweaker from ReplayModTweaker");
Launch.classLoader.addClassLoaderExclusion("org.spongepowered.asm.launch.MixinTweaker".substring(0, "org.spongepowered.asm.launch.MixinTweaker".lastIndexOf('.')));
List<ITweaker> tweaks = (List<ITweaker>)Launch.blackboard.get("Tweaks");
try {
tweaks.add((ITweaker)Class.forName("org.spongepowered.asm.launch.MixinTweaker", true, (ClassLoader)Launch.classLoader).newInstance());
} catch (InstantiationException|IllegalAccessException|ClassNotFoundException e) {
throw new RuntimeException(e);
}
}

public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {}

public void injectIntoClassLoader(LaunchClassLoader classLoader) {
URI uri;
try {
uri = getClass().getProtectionDomain().getCodeSource().getLocation().toURI();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
MixinPlatformManager platform = MixinBootstrap.getPlatform();
platform.addContainer(new ContainerHandleURI(uri));
}

public String getLaunchTarget() {
return null;
}

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")).booleanValue()) {
System.out.println("ReplayMod not initializing ModCore because we're in a development environment.");
return;
}
int result = ModCoreInstaller.initialize(Launch.minecraftHome, mcVer + "_forge");
if (result != -2)
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();
}
}
}

0 comments on commit 6a9ab0b

Please sign in to comment.