fix some incompatibility issues and a crash by using standardized FML loading

This commit is contained in:
TudbuT 2022-09-26 14:42:30 +02:00
parent eb818ea399
commit f396ff00bc
9 changed files with 35 additions and 28 deletions

View File

@ -88,8 +88,10 @@ jar {
"Implementation-Timestamp": new Date().format("yyyy-MM-dd"-"HH:mm:ssZ"),
"TweakClass": "org.spongepowered.asm.launch.MixinTweaker",
"TweakOrder": "0",
"FMLCorePluginContainsFMLMod": "de.enzaxd.viaforge.injection.MixinLoader",
"MixinConfigs": "mixins.${mod_id}.json"
"FMLCorePluginContainsFMLMod": "true",
"FMLCorePlugin": "de.enzaxd.viaforge.injection.MixinLoader",
"MixinConfigs": "mixins.${mod_id}.json",
"ForceLoadAsMod": "true"
)
enabled = false
}

0
gradlew vendored Normal file → Executable file
View File

0
gradlew.bat vendored Normal file → Executable file
View File

View File

@ -20,11 +20,16 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.logging.Logger;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
@Mod(modid = "viaforge", name = "ViaForge", version = "1.0.0")
public class ViaForge {
public final static int SHARED_VERSION = 340;
private static final ViaForge instance = new ViaForge();
private static ViaForge instance = null;
{ instance = this; } // called when forge initializes the mod
private final Logger jLogger = new JLoggerToLog4j(LogManager.getLogger("ViaForge"));
private final CompletableFuture<Void> initFuture = new CompletableFuture<>();
private ExecutorService asyncExecutor;
@ -37,7 +42,8 @@ public class ViaForge {
return instance;
}
public void start() {
@Mod.EventHandler
public void init(FMLPreInitializationEvent event) {
ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat("ViaForge-%d").build();
asyncExecutor = Executors.newFixedThreadPool(8, factory);

View File

@ -1,22 +0,0 @@
package de.enzaxd.viaforge.injection.mixins;
import de.enzaxd.viaforge.ViaForge;
import net.minecraft.client.Minecraft;
import net.minecraft.client.main.GameConfiguration;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Minecraft.class)
public abstract class MixinMinecraft {
@Inject(method = "<init>", at = @At("RETURN"))
public void injectConstructor(GameConfiguration p_i45547_1_, CallbackInfo ci) {
try {
ViaForge.getInstance().start();
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -62,6 +62,6 @@ public enum ProtocolCollection {
for (ProtocolCollection coll : values())
if (coll.getVersion().getVersion() == id)
return coll.getVersion();
return null;
return R1_12_2.getVersion();
}
}

View File

@ -0,0 +1,16 @@
[
{
"modid": "viaforge",
"name": "ViaForge",
"description": "",
"version": "1.0.0",
"mcversion": "1.12.2",
"url": "https://github.com/FlorianMichael/ViaForge",
"updateUrl": "",
"authorList": [],
"credits": "",
"logoFile": "",
"screenshots": [],
"dependencies": []
}
]

View File

@ -11,7 +11,6 @@
"MixinGuiMultiplayer",
"MixinGuiScreenAddServer",
"MixinGuiScreenServerList",
"MixinMinecraft",
"MixinNetworkManagerChInit"
],
"verbose": true

View File

@ -0,0 +1,6 @@
{
"pack": {
"description": "ViaForge",
"pack_format": 3
}
}