From 3c526a6cd4e60e262b01d298f5425f12c578785e Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Sat, 23 May 2020 22:31:01 +0200 Subject: [PATCH] Support MM1 in addition to MM2 (fixes #162) Cause the latest OptiFabric on 1.14.4 still ships that and it has no support for entrypoints. --- .../java/com/replaymod/core/ReplayModMMLauncher.java | 10 ++++++++++ src/main/resources/fabric.mod.json | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/main/java/com/replaymod/core/ReplayModMMLauncher.java b/src/main/java/com/replaymod/core/ReplayModMMLauncher.java index ceec12b0..e8de4c90 100644 --- a/src/main/java/com/replaymod/core/ReplayModMMLauncher.java +++ b/src/main/java/com/replaymod/core/ReplayModMMLauncher.java @@ -12,8 +12,18 @@ 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 { + private static boolean ran; + @Override public void run() { + // If this is MM2, then we're currently getting called because of our entrypoint declaration. + // For backwards compatibility with MM1, we also declare our early_riser via custom metadata and MM2 supports + // that as well and will therefore call us twice. + if (ran) { + return; + } + ran = true; + Mixins.addConfiguration("mixins.compat.mapwriter.replaymod.json"); Mixins.addConfiguration("mixins.compat.shaders.replaymod.json"); Mixins.addConfiguration("mixins.core.replaymod.json"); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 2a3593a7..0a41463d 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -40,6 +40,9 @@ }, "custom": { + "mm:early_risers": [ + "com.replaymod.core.ReplayModMMLauncher" + ], "modmenu:clientsideOnly": true } }