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..115749be --- /dev/null +++ b/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java @@ -0,0 +1,27 @@ +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; + +/* Optifine 1.4.3+ */ +@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/ReflectorMixin.java b/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorMixin.java new file mode 100644 index 00000000..f1152cf9 --- /dev/null +++ b/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorMixin.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; + +import java.util.Map; + +/* Optifine 1.3-1.4.2 */ +@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/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..03fcb1f9 --- /dev/null +++ b/1.3-1.5.2/src/main/resources/optifabric.optifine.mixins.json @@ -0,0 +1,9 @@ +{ + "required": true, + "package": "me.modmuss50.optifabric.mixin", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "ReflectorClassMixin", + "ReflectorMixin" + ] +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index d09dbef1..80e2ed13 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.5" } }