From 75cfc0c4def0854b2a9dced9a44e1ce2bafe751b Mon Sep 17 00:00:00 2001 From: Cat Core Date: Fri, 27 Sep 2024 17:49:22 +0200 Subject: [PATCH 1/5] Improve compatibility with Fabricated Legacy Forge --- .../optifabric/mixin/ReflectorClassMixin.java | 26 +++++++++++++++++++ .../optifabric/mixin/TitleScreenMixin.java | 3 ++- .../resources/optifabric.optifine.mixins.json | 8 ++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java create mode 100644 1.3-1.5.2/src/main/resources/optifabric.optifine.mixins.json diff --git a/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java b/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java new file mode 100644 index 00000000..ccc37a6b --- /dev/null +++ b/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java @@ -0,0 +1,26 @@ +package me.modmuss50.optifabric.mixin; + +import net.fabricmc.loader.api.FabricLoader; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Pseudo +@Mixin(targets = "ReflectorClass") +public abstract class ReflectorClassMixin { + @SuppressWarnings("UnresolvedMixinReference") + @Redirect(method = "getTargetClass", at = @At(value = "INVOKE", target = "Ljava/lang/Class;forName(Ljava/lang/String;)Ljava/lang/Class;", remap = false), remap = false) + private Class fixClassNameForFabricatedForge(String className) throws ClassNotFoundException { + try { + return Class.forName(className); + } catch (ClassNotFoundException exception) { + if (FabricLoader.getInstance().isModLoaded("fabricated-forge")) { + return Class.forName("net.minecraft." + className); + } else { + throw exception; + } + } + + } +} diff --git a/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/TitleScreenMixin.java b/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/TitleScreenMixin.java index ed86be9c..5edcecb7 100644 --- a/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/TitleScreenMixin.java +++ b/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/TitleScreenMixin.java @@ -1,6 +1,7 @@ package me.modmuss50.optifabric.mixin; import me.modmuss50.optifabric.mod.*; +import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.*; import org.spongepowered.asm.mixin.Mixin; @@ -18,7 +19,7 @@ private void init(CallbackInfo info) { @Inject(method = "render", at = @At("RETURN")) private void render(CallbackInfo ci) { - if (!Optifabric.hasError()) { + if (!Optifabric.hasError() && !FabricLoader.getInstance().isModLoaded("fabricated-forge")) { this.drawWithShadow(Minecraft.getMinecraft().textRenderer, OptifineVersion.version, 2, this.height - 20, 0xFFFFFFFF); } } diff --git a/1.3-1.5.2/src/main/resources/optifabric.optifine.mixins.json b/1.3-1.5.2/src/main/resources/optifabric.optifine.mixins.json new file mode 100644 index 00000000..d7cc178e --- /dev/null +++ b/1.3-1.5.2/src/main/resources/optifabric.optifine.mixins.json @@ -0,0 +1,8 @@ +{ + "required": true, + "package": "me.modmuss50.optifabric.mixin", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "ReflectorClassMixin" + ] +} From 7161f392143cf4d38c4b7d85f25c043e8badcf17 Mon Sep 17 00:00:00 2001 From: Cat Core Date: Fri, 27 Sep 2024 18:29:43 +0200 Subject: [PATCH 2/5] Improve compatibility with Fabricated Legacy Forge on older Optifine versions --- .../optifabric/mixin/ReflectorMixin.java | 25 +++++++++++++++++++ .../resources/optifabric.optifine.mixins.json | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorMixin.java diff --git a/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorMixin.java b/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorMixin.java new file mode 100644 index 00000000..2cbdd978 --- /dev/null +++ b/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorMixin.java @@ -0,0 +1,25 @@ +package me.modmuss50.optifabric.mixin; + +import net.fabricmc.loader.api.FabricLoader; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import java.util.Map; + +@Pseudo +@Mixin(targets = "Reflector") +public class ReflectorMixin { + @SuppressWarnings("UnresolvedMixinReference") + @Redirect(method = "getClassNameMap", at = @At(value = "INVOKE", target = "Ljava/util/Map;put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", remap = false), remap = false) + private static Object fixClassNameForFabricatedForge(Map map, Object key, Object value) { + if (FabricLoader.getInstance().isModLoaded("fabricated-forge")) { + if (value instanceof String && !((String) value).contains(".")) { + value = "net.minecraft." + value; + } + } + + return map.put(key, value); + } +} diff --git a/1.3-1.5.2/src/main/resources/optifabric.optifine.mixins.json b/1.3-1.5.2/src/main/resources/optifabric.optifine.mixins.json index d7cc178e..03fcb1f9 100644 --- a/1.3-1.5.2/src/main/resources/optifabric.optifine.mixins.json +++ b/1.3-1.5.2/src/main/resources/optifabric.optifine.mixins.json @@ -3,6 +3,7 @@ "package": "me.modmuss50.optifabric.mixin", "compatibilityLevel": "JAVA_8", "mixins": [ - "ReflectorClassMixin" + "ReflectorClassMixin", + "ReflectorMixin" ] } From ede4763c35998556d4ec4d6b5b0eeea13d08d474 Mon Sep 17 00:00:00 2001 From: Cat Core Date: Fri, 27 Sep 2024 19:06:09 +0200 Subject: [PATCH 3/5] Add break for non compatible versions of FLF --- src/main/resources/fabric.mod.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index d09dbef1..e62a0c24 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,5 +30,8 @@ "depends": { "fabricloader": ">=0.14", "minecraft": ">=1.3 <=1.13.2" + }, + "breaks": { + "fabricated-forge": "<=2.7.2" } } From 9aca0da8e951af4ae2a5c61d1916f0b169433095 Mon Sep 17 00:00:00 2001 From: Cat Core Date: Mon, 21 Oct 2024 20:59:09 +0200 Subject: [PATCH 4/5] Add comment to mixins --- .../java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java | 1 + .../main/java/me/modmuss50/optifabric/mixin/ReflectorMixin.java | 1 + 2 files changed, 2 insertions(+) diff --git a/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java b/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java index ccc37a6b..115749be 100644 --- a/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java +++ b/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java @@ -6,6 +6,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; +/* Optifine 1.4.3+ */ @Pseudo @Mixin(targets = "ReflectorClass") public abstract class ReflectorClassMixin { diff --git a/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorMixin.java b/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorMixin.java index 2cbdd978..f1152cf9 100644 --- a/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorMixin.java +++ b/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorMixin.java @@ -8,6 +8,7 @@ import java.util.Map; +/* Optifine 1.3-1.4.2 */ @Pseudo @Mixin(targets = "Reflector") public class ReflectorMixin { From 840344ebfc64090368b79364f2aa655456987038 Mon Sep 17 00:00:00 2001 From: Cat Core Date: Mon, 21 Oct 2024 21:00:31 +0200 Subject: [PATCH 5/5] Update FLF version breakage --- src/main/resources/fabric.mod.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index e62a0c24..80e2ed13 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -32,6 +32,6 @@ "minecraft": ">=1.3 <=1.13.2" }, "breaks": { - "fabricated-forge": "<=2.7.2" + "fabricated-forge": "<2.7.5" } }