diff --git a/1.13.2/build.gradle b/1.13.2/build.gradle new file mode 100644 index 00000000..c0a7572f --- /dev/null +++ b/1.13.2/build.gradle @@ -0,0 +1,10 @@ +plugins { + id "loom" + id "legacy-looming" +} + +dependencies { + minecraft "com.mojang:minecraft:$minecraft_version" + mappings(legacy.yarn(minecraft_version, yarn_build)) + implementation project(path: ":", configuration: "namedElements") +} diff --git a/1.13.2/gradle.properties b/1.13.2/gradle.properties new file mode 100644 index 00000000..2ce5fae4 --- /dev/null +++ b/1.13.2/gradle.properties @@ -0,0 +1,2 @@ +minecraft_version=1.13.2 +yarn_build=533 diff --git a/src/main/java/me/modmuss50/optifabric/mixin/PatcherMixin.java b/1.13.2/src/main/java/me/modmuss50/optifabric/mixin/PatcherMixin.java similarity index 67% rename from src/main/java/me/modmuss50/optifabric/mixin/PatcherMixin.java rename to 1.13.2/src/main/java/me/modmuss50/optifabric/mixin/PatcherMixin.java index 0eb0bb1d..8870e1c7 100644 --- a/src/main/java/me/modmuss50/optifabric/mixin/PatcherMixin.java +++ b/1.13.2/src/main/java/me/modmuss50/optifabric/mixin/PatcherMixin.java @@ -4,11 +4,11 @@ import org.spongepowered.asm.mixin.injection.*; @Pseudo -@Mixin(targets = "optifine.Patcher", remap = false) -public class PatcherMixin { +@Mixin(targets = "optifine.Patcher") +public abstract class PatcherMixin { + @SuppressWarnings("UnresolvedMixinReference") @Redirect(method = "process", at = @At(value = "INVOKE", target = "Ljava/lang/String;equals(Ljava/lang/Object;)Z")) private static boolean ignoreHashFailure(String instance, Object o) { - // not used for anything at the moment but could fix issues with named mappings? return true; } } diff --git a/1.13.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java b/1.13.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java new file mode 100644 index 00000000..c59abc1a --- /dev/null +++ b/1.13.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java @@ -0,0 +1,27 @@ +package me.modmuss50.optifabric.mixin; + +import org.spongepowered.asm.mixin.*; +import org.spongepowered.asm.mixin.injection.*; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +// suppresses some warnings in the log +@Pseudo +@Mixin(targets = "ReflectorClass") +public class ReflectorClassMixin { + @Shadow + private String targetClassName; + + @Shadow + private boolean checked; + + @SuppressWarnings("UnresolvedMixinReference") + @Inject(method = "getTargetClass", at = @At("HEAD"), remap = false) + private void getTargetClass(CallbackInfoReturnable> infoReturnable) { + if (!checked) { // only check the target if it hasn't been done yet + String name = targetClassName.replaceAll("/", "."); + if (name.startsWith("net.minecraft.launchwrapper") || name.startsWith("net.minecraftforge") || "optifine.OptiFineClassTransformer".equals(name)) { + checked = true; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/me/modmuss50/optifabric/mixin/TitleScreenMixin.java b/1.13.2/src/main/java/me/modmuss50/optifabric/mixin/TitleScreenMixin.java similarity index 100% rename from src/main/java/me/modmuss50/optifabric/mixin/TitleScreenMixin.java rename to 1.13.2/src/main/java/me/modmuss50/optifabric/mixin/TitleScreenMixin.java diff --git a/1.13.2/src/main/resources/fabric.mod.json b/1.13.2/src/main/resources/fabric.mod.json new file mode 100644 index 00000000..a7b720cb --- /dev/null +++ b/1.13.2/src/main/resources/fabric.mod.json @@ -0,0 +1,28 @@ +{ + "schemaVersion": 1, + "id": "optifabric-mixin", + "version": "${version}", + "name": "Optifabric Mixin", + "description": "Optifabric is a mod that loads Optifine into Fabric", + "authors": [ + "Modmuss50", + "Chocohead", + "Hydos", + "RedLime", + "tildejustin" + ], + "contact": { + "homepage": "https://modrinth.com/mod/legacy-optifabric", + "sources": "https://github.com/tildejustin/optifabric", + "issues": "https://github.com/tildejustin/optifabric/issues" + }, + "mixins": [ + "optifabric.mixins.json" + ], + "license": "MPL-2.0", + "environment": "client", + "depends": { + "fabricloader": ">=0.14", + "minecraft": ">=1.13 <=1.13.2" + } +} diff --git a/src/main/resources/optifabric.mixins.json b/1.13.2/src/main/resources/optifabric.mixins.json similarity index 100% rename from src/main/resources/optifabric.mixins.json rename to 1.13.2/src/main/resources/optifabric.mixins.json diff --git a/1.13.2/src/main/resources/optifabric.optifine.mixins.json b/1.13.2/src/main/resources/optifabric.optifine.mixins.json new file mode 100644 index 00000000..07e82697 --- /dev/null +++ b/1.13.2/src/main/resources/optifabric.optifine.mixins.json @@ -0,0 +1,9 @@ +{ + "required": true, + "package": "me.modmuss50.optifabric.mixin", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "PatcherMixin", + "ReflectorClassMixin" + ] +} diff --git a/1.3-1.5.2/build.gradle b/1.3-1.5.2/build.gradle new file mode 100644 index 00000000..c0a7572f --- /dev/null +++ b/1.3-1.5.2/build.gradle @@ -0,0 +1,10 @@ +plugins { + id "loom" + id "legacy-looming" +} + +dependencies { + minecraft "com.mojang:minecraft:$minecraft_version" + mappings(legacy.yarn(minecraft_version, yarn_build)) + implementation project(path: ":", configuration: "namedElements") +} diff --git a/1.3-1.5.2/gradle.properties b/1.3-1.5.2/gradle.properties new file mode 100644 index 00000000..8d90ce96 --- /dev/null +++ b/1.3-1.5.2/gradle.properties @@ -0,0 +1,2 @@ +minecraft_version=1.3.2 +yarn_build=533 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 new file mode 100644 index 00000000..ed86be9c --- /dev/null +++ b/1.3-1.5.2/src/main/java/me/modmuss50/optifabric/mixin/TitleScreenMixin.java @@ -0,0 +1,25 @@ +package me.modmuss50.optifabric.mixin; + +import me.modmuss50.optifabric.mod.*; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screen.*; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.*; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(TitleScreen.class) +public abstract class TitleScreenMixin extends Screen { + @Inject(method = "init", at = @At("RETURN")) + private void init(CallbackInfo info) { + if (Optifabric.hasError()) { + System.out.println("an optifabric error has occurred"); + } + } + + @Inject(method = "render", at = @At("RETURN")) + private void render(CallbackInfo ci) { + if (!Optifabric.hasError()) { + this.drawWithShadow(Minecraft.getMinecraft().textRenderer, OptifineVersion.version, 2, this.height - 20, 0xFFFFFFFF); + } + } +} diff --git a/1.3-1.5.2/src/main/resources/fabric.mod.json b/1.3-1.5.2/src/main/resources/fabric.mod.json new file mode 100644 index 00000000..40bc4951 --- /dev/null +++ b/1.3-1.5.2/src/main/resources/fabric.mod.json @@ -0,0 +1,29 @@ +{ + "schemaVersion": 1, + "id": "optifabric-mixin", + "version": "${version}", + "name": "Optifabric Mixin", + "description": "Optifabric is a mod that loads Optifine into Fabric", + "authors": [ + "Modmuss50", + "Chocohead", + "Hydos", + "RedLime", + "tildejustin" + ], + "contact": { + "homepage": "https://modrinth.com/mod/legacy-optifabric", + "sources": "https://github.com/tildejustin/optifabric", + "issues": "https://github.com/tildejustin/optifabric/issues" + }, + "mixins": [ + "optifabric.mixins.json" + ], + "license": "MPL-2.0", + "environment": "client", + "depends": { + "fabricloader": ">=0.14", + "minecraft": ">=1.3 <=1.5.2" + }, + "accessWidener": "optifabric.accesswidener" +} diff --git a/1.3-1.5.2/src/main/resources/optifabric.accesswidener b/1.3-1.5.2/src/main/resources/optifabric.accesswidener new file mode 100644 index 00000000..22139c33 --- /dev/null +++ b/1.3-1.5.2/src/main/resources/optifabric.accesswidener @@ -0,0 +1,9 @@ +accessWidener v2 named +accessible field net/minecraft/client/gui/widget/ButtonWidget width I +accessible field net/minecraft/client/gui/widget/ButtonWidget height I +accessible field net/minecraft/client/option/GameOptions field_946 Lnet/minecraft/client/Minecraft; +accessible field net/minecraft/client/particle/Particle red F +accessible field net/minecraft/client/particle/Particle green F +accessible field net/minecraft/client/particle/Particle blue F +accessible field net/minecraft/world/World levelProperties Lnet/minecraft/world/level/LevelProperties; +accessible field net/minecraft/client/render/GameRenderer lightmapFlicker F diff --git a/1.3-1.5.2/src/main/resources/optifabric.mixins.json b/1.3-1.5.2/src/main/resources/optifabric.mixins.json new file mode 100644 index 00000000..44f85574 --- /dev/null +++ b/1.3-1.5.2/src/main/resources/optifabric.mixins.json @@ -0,0 +1,8 @@ +{ + "required": true, + "package": "me.modmuss50.optifabric.mixin", + "compatibilityLevel": "JAVA_8", + "client": [ + "TitleScreenMixin" + ] +} diff --git a/1.6-1.7.10/build.gradle b/1.6-1.7.10/build.gradle new file mode 100644 index 00000000..c0a7572f --- /dev/null +++ b/1.6-1.7.10/build.gradle @@ -0,0 +1,10 @@ +plugins { + id "loom" + id "legacy-looming" +} + +dependencies { + minecraft "com.mojang:minecraft:$minecraft_version" + mappings(legacy.yarn(minecraft_version, yarn_build)) + implementation project(path: ":", configuration: "namedElements") +} diff --git a/1.6-1.7.10/gradle.properties b/1.6-1.7.10/gradle.properties new file mode 100644 index 00000000..c0913252 --- /dev/null +++ b/1.6-1.7.10/gradle.properties @@ -0,0 +1,2 @@ +minecraft_version=1.7.10 +yarn_build=533 diff --git a/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java b/1.6-1.7.10/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java similarity index 79% rename from src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java rename to 1.6-1.7.10/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java index 7cf013e2..a6ee537e 100644 --- a/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java +++ b/1.6-1.7.10/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java @@ -4,9 +4,9 @@ import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -// suppresses some warnings in the log +// suppresses some warnings in the logs @Pseudo -@Mixin(targets = "net.optifine.reflect.ReflectorClass", remap = false) +@Mixin(targets = "ReflectorClass") public class ReflectorClassMixin { @Shadow private String targetClassName; @@ -14,10 +14,10 @@ public class ReflectorClassMixin { @Shadow private boolean checked; + @SuppressWarnings("UnresolvedMixinReference") @Inject(method = "getTargetClass", at = @At("HEAD"), remap = false) private void getTargetClass(CallbackInfoReturnable> infoReturnable) { - if (!this.checked) { - // only check the target if it hasn't been done yet + if (!this.checked) { // only check the target if it hasn't been done yet String name = this.targetClassName.replaceAll("/", "."); if (name.startsWith("net.minecraft.launchwrapper") || name.startsWith("net.minecraftforge") || "optifine.OptiFineClassTransformer".equals(name)) { this.checked = true; diff --git a/1.6-1.7.10/src/main/java/me/modmuss50/optifabric/mixin/TitleScreenMixin.java b/1.6-1.7.10/src/main/java/me/modmuss50/optifabric/mixin/TitleScreenMixin.java new file mode 100644 index 00000000..c1b24d50 --- /dev/null +++ b/1.6-1.7.10/src/main/java/me/modmuss50/optifabric/mixin/TitleScreenMixin.java @@ -0,0 +1,25 @@ +package me.modmuss50.optifabric.mixin; + +import me.modmuss50.optifabric.mod.*; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.*; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.*; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(TitleScreen.class) +public abstract class TitleScreenMixin extends Screen { + @Inject(method = "init", at = @At("RETURN")) + private void init(CallbackInfo info) { + if (Optifabric.hasError()) { + System.out.println("an optifabric error has occurred"); + } + } + + @Inject(method = "render", at = @At("RETURN")) + private void render(CallbackInfo ci) { + if (!Optifabric.hasError()) { + this.drawWithShadow(MinecraftClient.getInstance().textRenderer, OptifineVersion.version, 2, this.height - 20, 0xFFFFFFFF); + } + } +} diff --git a/1.6-1.7.10/src/main/resources/fabric.mod.json b/1.6-1.7.10/src/main/resources/fabric.mod.json new file mode 100644 index 00000000..1b718cf7 --- /dev/null +++ b/1.6-1.7.10/src/main/resources/fabric.mod.json @@ -0,0 +1,29 @@ +{ + "schemaVersion": 1, + "id": "optifabric-mixin", + "version": "${version}", + "name": "Optifabric Mixin", + "description": "Optifabric is a mod that loads Optifine into Fabric", + "authors": [ + "Modmuss50", + "Chocohead", + "Hydos", + "RedLime", + "tildejustin" + ], + "contact": { + "homepage": "https://modrinth.com/mod/legacy-optifabric", + "sources": "https://github.com/tildejustin/optifabric", + "issues": "https://github.com/tildejustin/optifabric/issues" + }, + "mixins": [ + "optifabric.mixins.json" + ], + "license": "MPL-2.0", + "environment": "client", + "depends": { + "fabricloader": ">=0.14", + "minecraft": ">=1.6 <=1.7.10" + }, + "accessWidener": "optifabric.accesswidener" +} diff --git a/1.6-1.7.10/src/main/resources/optifabric.accesswidener b/1.6-1.7.10/src/main/resources/optifabric.accesswidener new file mode 100644 index 00000000..4259a01d --- /dev/null +++ b/1.6-1.7.10/src/main/resources/optifabric.accesswidener @@ -0,0 +1,14 @@ +accessWidener v2 named +accessible method net/minecraft/block/Block setOpacity (I)Lnet/minecraft/block/Block; +accessible field net/minecraft/resource/AbstractFileResourcePack base Ljava/io/File; +accessible field net/minecraft/entity/LivingEntity despawnCounter I +accessible method net/minecraft/entity/mob/MobEntity checkDespawn ()V +accessible method net/minecraft/util/Language getInstance ()Lnet/minecraft/util/Language; +accessible field net/minecraft/client/particle/Particle red F +accessible field net/minecraft/client/particle/Particle green F +accessible field net/minecraft/client/particle/Particle blue F +accessible field net/minecraft/client/gui/widget/ButtonWidget width I +accessible field net/minecraft/client/gui/widget/ButtonWidget height I +accessible method net/minecraft/client/texture/TextureUtil bindTexture (I)V +accessible field net/minecraft/client/render/GameRenderer lightmapFlicker F +accessible method net/minecraft/block/Block method_462 (I)Lnet/minecraft/block/Block; diff --git a/1.6-1.7.10/src/main/resources/optifabric.mixins.json b/1.6-1.7.10/src/main/resources/optifabric.mixins.json new file mode 100644 index 00000000..44f85574 --- /dev/null +++ b/1.6-1.7.10/src/main/resources/optifabric.mixins.json @@ -0,0 +1,8 @@ +{ + "required": true, + "package": "me.modmuss50.optifabric.mixin", + "compatibilityLevel": "JAVA_8", + "client": [ + "TitleScreenMixin" + ] +} diff --git a/1.6-1.7.10/src/main/resources/optifabric.optifine.mixins.json b/1.6-1.7.10/src/main/resources/optifabric.optifine.mixins.json new file mode 100644 index 00000000..d7cc178e --- /dev/null +++ b/1.6-1.7.10/src/main/resources/optifabric.optifine.mixins.json @@ -0,0 +1,8 @@ +{ + "required": true, + "package": "me.modmuss50.optifabric.mixin", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "ReflectorClassMixin" + ] +} diff --git a/1.8-1.12.2/build.gradle b/1.8-1.12.2/build.gradle new file mode 100644 index 00000000..c0a7572f --- /dev/null +++ b/1.8-1.12.2/build.gradle @@ -0,0 +1,10 @@ +plugins { + id "loom" + id "legacy-looming" +} + +dependencies { + minecraft "com.mojang:minecraft:$minecraft_version" + mappings(legacy.yarn(minecraft_version, yarn_build)) + implementation project(path: ":", configuration: "namedElements") +} diff --git a/1.8-1.12.2/gradle.properties b/1.8-1.12.2/gradle.properties new file mode 100644 index 00000000..300725f7 --- /dev/null +++ b/1.8-1.12.2/gradle.properties @@ -0,0 +1,2 @@ +minecraft_version=1.12.2 +yarn_build=533 diff --git a/src/main/java/me/modmuss50/optifabric/mixin/NativeMemoryMixin.java b/1.8-1.12.2/src/main/java/me/modmuss50/optifabric/mixin/NativeMemoryMixin.java similarity index 80% rename from src/main/java/me/modmuss50/optifabric/mixin/NativeMemoryMixin.java rename to 1.8-1.12.2/src/main/java/me/modmuss50/optifabric/mixin/NativeMemoryMixin.java index 6334b507..7b7f3031 100644 --- a/src/main/java/me/modmuss50/optifabric/mixin/NativeMemoryMixin.java +++ b/1.8-1.12.2/src/main/java/me/modmuss50/optifabric/mixin/NativeMemoryMixin.java @@ -4,11 +4,11 @@ import org.spongepowered.asm.mixin.injection.*; @Pseudo -@Mixin(targets = "net.optifine.util.NativeMemory", remap = false) +@Mixin(targets = "net.optifine.util.NativeMemory") public class NativeMemoryMixin { + @SuppressWarnings("UnresolvedMixinReference") @ModifyArg(method = "", at = @At(value = "INVOKE", target = "Lnet/optifine/util/NativeMemory;makeLongSupplier([[Ljava/lang/String;)Ljava/util/function/LongSupplier;", ordinal = 0)) private static String[][] addNewSharedSecretsLocation(String[][] paths) { - // package of SharedSecrets changed in java 12, add the new location return new String[][]{paths[0], paths[1], {"jdk.internal.access.SharedSecrets", "getJavaNioAccess", "getDirectBufferPool", "getMemoryUsed"}}; } } diff --git a/1.8-1.12.2/src/main/java/me/modmuss50/optifabric/mixin/PatcherMixin.java b/1.8-1.12.2/src/main/java/me/modmuss50/optifabric/mixin/PatcherMixin.java new file mode 100644 index 00000000..8870e1c7 --- /dev/null +++ b/1.8-1.12.2/src/main/java/me/modmuss50/optifabric/mixin/PatcherMixin.java @@ -0,0 +1,14 @@ +package me.modmuss50.optifabric.mixin; + +import org.spongepowered.asm.mixin.*; +import org.spongepowered.asm.mixin.injection.*; + +@Pseudo +@Mixin(targets = "optifine.Patcher") +public abstract class PatcherMixin { + @SuppressWarnings("UnresolvedMixinReference") + @Redirect(method = "process", at = @At(value = "INVOKE", target = "Ljava/lang/String;equals(Ljava/lang/Object;)Z")) + private static boolean ignoreHashFailure(String instance, Object o) { + return true; + } +} diff --git a/1.8-1.12.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java b/1.8-1.12.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java new file mode 100644 index 00000000..2e9ea5a8 --- /dev/null +++ b/1.8-1.12.2/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java @@ -0,0 +1,27 @@ +package me.modmuss50.optifabric.mixin; + +import org.spongepowered.asm.mixin.*; +import org.spongepowered.asm.mixin.injection.*; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +// suppresses some warnings in the logs +@Pseudo +@Mixin(targets = "net.optifine.reflect.ReflectorClass") +public class ReflectorClassMixin { + @Shadow + private String targetClassName; + + @Shadow + private boolean checked; + + @SuppressWarnings("UnresolvedMixinReference") + @Inject(method = "getTargetClass", at = @At("HEAD"), remap = false) + private void getTargetClass(CallbackInfoReturnable> infoReturnable) { + if (!this.checked) { // only check the target if it hasn't been done yet + String name = this.targetClassName.replaceAll("/", "."); + if (name.startsWith("net.minecraft.launchwrapper") || name.startsWith("net.minecraftforge") || "optifine.OptiFineClassTransformer".equals(name)) { + this.checked = true; + } + } + } +} diff --git a/1.8-1.12.2/src/main/java/me/modmuss50/optifabric/mixin/TitleScreenMixin.java b/1.8-1.12.2/src/main/java/me/modmuss50/optifabric/mixin/TitleScreenMixin.java new file mode 100644 index 00000000..c1b24d50 --- /dev/null +++ b/1.8-1.12.2/src/main/java/me/modmuss50/optifabric/mixin/TitleScreenMixin.java @@ -0,0 +1,25 @@ +package me.modmuss50.optifabric.mixin; + +import me.modmuss50.optifabric.mod.*; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.*; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.*; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(TitleScreen.class) +public abstract class TitleScreenMixin extends Screen { + @Inject(method = "init", at = @At("RETURN")) + private void init(CallbackInfo info) { + if (Optifabric.hasError()) { + System.out.println("an optifabric error has occurred"); + } + } + + @Inject(method = "render", at = @At("RETURN")) + private void render(CallbackInfo ci) { + if (!Optifabric.hasError()) { + this.drawWithShadow(MinecraftClient.getInstance().textRenderer, OptifineVersion.version, 2, this.height - 20, 0xFFFFFFFF); + } + } +} diff --git a/1.8-1.12.2/src/main/resources/fabric.mod.json b/1.8-1.12.2/src/main/resources/fabric.mod.json new file mode 100644 index 00000000..bd8b0fa4 --- /dev/null +++ b/1.8-1.12.2/src/main/resources/fabric.mod.json @@ -0,0 +1,29 @@ +{ + "schemaVersion": 1, + "id": "optifabric-mixin", + "version": "${version}", + "name": "Optifabric Mixin", + "description": "Optifabric is a mod that loads Optifine into Fabric", + "authors": [ + "Modmuss50", + "Chocohead", + "Hydos", + "RedLime", + "tildejustin" + ], + "contact": { + "homepage": "https://modrinth.com/mod/legacy-optifabric", + "sources": "https://github.com/tildejustin/optifabric", + "issues": "https://github.com/tildejustin/optifabric/issues" + }, + "mixins": [ + "optifabric.mixins.json" + ], + "license": "MPL-2.0", + "environment": "client", + "depends": { + "fabricloader": ">=0.14", + "minecraft": ">=1.8 <=1.12.2" + }, + "accessWidener": "optifabric.accesswidener" +} diff --git a/1.8-1.12.2/src/main/resources/optifabric.accesswidener b/1.8-1.12.2/src/main/resources/optifabric.accesswidener new file mode 100644 index 00000000..d64b4e28 --- /dev/null +++ b/1.8-1.12.2/src/main/resources/optifabric.accesswidener @@ -0,0 +1,2 @@ +accessWidener v2 named +# i could not find a broken access in 1.8-1.12.2, but i am not confident enough in that being true across the board to get rid of the accesswidener diff --git a/1.8-1.12.2/src/main/resources/optifabric.mixins.json b/1.8-1.12.2/src/main/resources/optifabric.mixins.json new file mode 100644 index 00000000..44f85574 --- /dev/null +++ b/1.8-1.12.2/src/main/resources/optifabric.mixins.json @@ -0,0 +1,8 @@ +{ + "required": true, + "package": "me.modmuss50.optifabric.mixin", + "compatibilityLevel": "JAVA_8", + "client": [ + "TitleScreenMixin" + ] +} diff --git a/src/main/resources/optifabric.optifine.mixins.json b/1.8-1.12.2/src/main/resources/optifabric.optifine.mixins.json similarity index 100% rename from src/main/resources/optifabric.optifine.mixins.json rename to 1.8-1.12.2/src/main/resources/optifabric.optifine.mixins.json diff --git a/build.gradle b/build.gradle index f380241a..b4807888 100644 --- a/build.gradle +++ b/build.gradle @@ -1,63 +1,18 @@ plugins { - alias libs.plugins.fabric.loom - alias libs.plugins.legacy.looming - id "maven-publish" + id "loom" + id "legacy-looming" } version = "$mod_version+$target_version" -group = maven_group - -base { - archivesName = archives_name -} - -// intentionally do not apply accessWidener, makes it difficult to check the access and thus necessity of its contents -loom { - runConfigs.configureEach { - ideConfigGenerated = false - } -} - -repositories { - mavenLocal() - maven { url "https://jitpack.io" } -} dependencies { - minecraft libs.minecraft - mappings legacy.yarn(libs.versions.minecraft.get(), libs.versions.yarn.build.get()) - modImplementation libs.fabric.loader - include(modImplementation libs.fabric.asm.get()) - include(implementation libs.mapping.io.get()) - include(implementation libs.tiny.remapper.get()) - runtimeOnly(files "libs/optifine-mapped.jar") -} - -processResources { - filesMatching("fabric.mod.json") { - expand "version": version - } -} - -tasks.withType(JavaCompile).configureEach { - it.options.encoding = "UTF-8" - if (java.toolchain.languageVersion.get() >= JavaLanguageVersion.of(9)) it.options.release.set(8) -} - -java { - sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 - toolchain { - languageVersion = JavaLanguageVersion.of(8) - } -} - -jar { - from("LICENSE") -} - -publishing { - publications.create("mavenJava", MavenPublication) { - from components.java + minecraft "com.mojang:minecraft:$minecraft_version" + mappings legacy.yarn(minecraft_version, yarn_build) + include(modImplementation "com.github.Minecraft-Java-Edition-Speedrunning:fabric-asm:$fabric_asm_version") + include(implementation "net.fabricmc:mapping-io:$mapping_io_version") + include(implementation "net.fabricmc:tiny-remapper:$tiny_remapper_version") + + subprojects.forEach { + include project(path: it.path, configuration: "namedElements") } - repositories {} } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 00000000..b4019bdf --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,18 @@ +plugins { + id "groovy-gradle-plugin" +} + +repositories { + mavenCentral() + gradlePluginPortal() + maven { url "https://maven.fabricmc.net" } + maven { url "https://repo.legacyfabric.net/repository/legacyfabric" } + maven { url "https://maven.ornithemc.net/releases" } + maven { url "https://maven.ornithemc.net/snapshots" } +} + +dependencies { + implementation "fabric-loom:fabric-loom.gradle.plugin:$loom_version" + implementation "net.legacyfabric:legacy-looming:$legacy_looming_version" + implementation "ploceus:ploceus.gradle.plugin:$ploceus_version" +} diff --git a/buildSrc/gradle.properties b/buildSrc/gradle.properties new file mode 100644 index 00000000..650c8c11 --- /dev/null +++ b/buildSrc/gradle.properties @@ -0,0 +1,3 @@ +loom_version=1.4-SNAPSHOT +legacy_looming_version=1.4-SNAPSHOT +ploceus_version=1.4-SNAPSHOT diff --git a/buildSrc/src/main/groovy/loom.gradle b/buildSrc/src/main/groovy/loom.gradle new file mode 100644 index 00000000..cefc97ab --- /dev/null +++ b/buildSrc/src/main/groovy/loom.gradle @@ -0,0 +1,57 @@ +plugins { + id "fabric-loom" + id "maven-publish" +} + +var target_version = project.path.replace(":", "") +version = "$mod_version+$target_version" +group = maven_group + +base { + archivesName = archives_name +} + +loom { + decompilers { + vineflower { + options.putAll(["mark-corresponding-synthetics": "1", "ind": " "]) + } + } +} + +repositories { + maven { url "https://jitpack.io" } +} + +dependencies { + modImplementation "net.fabricmc:fabric-loader:$fabric_loader_version" +} + +processResources { + filesMatching("fabric.mod.json") { + expand "version": version, "target_version": target_version + } +} + +tasks.withType(JavaCompile).configureEach { + it.options.encoding = "UTF-8" + if (java.toolchain.languageVersion.get() >= JavaLanguageVersion.of(9)) it.options.release.set(8) +} + +java { + sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} + +jar { + from "LICENSE" +} + +publishing { + publications.create("mavenJava", MavenPublication) { + from components.java + } + repositories {} +} diff --git a/gradle.properties b/gradle.properties index cdca7d53..af9a1b22 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,13 @@ org.gradle.jvmargs=-Xmx2G org.gradle.parallel=true -mod_version=2.2.0 -target_version=1.8-1.12.2 +org.gradle.caching=false +minecraft_version=1.3.2 +target_version=1.3-1.13.2 +yarn_build=533 +mod_version=2.3.0 archives_name=optifabric maven_group=me.modmuss50 +fabric_loader_version=0.15.3 +fabric_asm_version=v2.3.3 +mapping_io_version=0.5.1 +tiny_remapper_version=0.10.0 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml deleted file mode 100644 index eb5e631e..00000000 --- a/gradle/libs.versions.toml +++ /dev/null @@ -1,19 +0,0 @@ -[versions] -minecraft = "1.8.9" -yarn_build = "533" -fabric-loader = "0.15.3" -loom = "1.4-SNAPSHOT" -fabric-asm = "v2.3.3" -mapping-io = "0.5.1" -tiny-remapper = "0.9.0" - -[libraries] -minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" } -fabric-loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric-loader" } -fabric-asm = { module = "com.github.Minecraft-Java-Edition-Speedrunning:fabric-asm", version.ref = "fabric-asm" } -mapping-io = { module = "net.fabricmc:mapping-io", version.ref = "mapping-io" } -tiny-remapper = { module = "net.fabricmc:tiny-remapper", version.ref = "tiny-remapper" } - -[plugins] -fabric_loom = { id = "fabric-loom", version.ref = "loom" } -legacy_looming = { id = "legacy-looming", version.ref = "loom" } diff --git a/libs/optifine-mapped.jar b/libs/optifine-mapped.jar deleted file mode 100644 index bc204069..00000000 Binary files a/libs/optifine-mapped.jar and /dev/null differ diff --git a/optifabric-hd-1.1-crash.log b/optifabric-hd-1.1-crash.log new file mode 100644 index 00000000..eff80720 --- /dev/null +++ b/optifabric-hd-1.1-crash.log @@ -0,0 +1,199 @@ +Prism Launcher version: 7.2 (official) + + +Launched instance in offline mode + +Minecraft folder is: +C:/Users/********/AppData/Roaming/PrismLauncher/instances/1.1/.minecraft + + +Java path is: +C:/Users/********/Downloads/jdk-22+19-jre/bin/javaw.exe + + +Java is version 22-beta, using 64 (amd64) architecture, from Eclipse Adoptium. + + +Main Class: + net.fabricmc.loader.impl.launch.knot.KnotClient + +Native path: + C:/Users/********/AppData/Roaming/PrismLauncher/instances/1.1/natives + +Traits: +traits texturepacks + +Libraries: + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/net/java/jinput/jinput/2.0.5/jinput-2.0.5.jar + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/net/java/jutils/jutils/1.0.0/jutils-1.0.0.jar + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/org/lwjgl/lwjgl/lwjgl/2.9.0/lwjgl-2.9.0.jar + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/org/lwjgl/lwjgl/lwjgl_util/2.9.0/lwjgl_util-2.9.0.jar + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/net/minecraft/launchwrapper/1.5/launchwrapper-1.5.jar + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/net/sf/jopt-simple/jopt-simple/4.5/jopt-simple-4.5.jar + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/net/ornithemc/calamus-intermediary/1.1-client/calamus-intermediary-1.1-client.jar + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/net/fabricmc/tiny-mappings-parser/0.3.0+build.17/tiny-mappings-parser-0.3.0+build.17.jar + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/net/fabricmc/sponge-mixin/0.12.5+mixin.0.8.5/sponge-mixin-0.12.5+mixin.0.8.5.jar + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/net/fabricmc/tiny-remapper/0.8.2/tiny-remapper-0.8.2.jar + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/net/fabricmc/access-widener/2.1.0/access-widener-2.1.0.jar + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/org/ow2/asm/asm/9.6/asm-9.6.jar + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/org/ow2/asm/asm-analysis/9.6/asm-analysis-9.6.jar + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/org/ow2/asm/asm-commons/9.6/asm-commons-9.6.jar + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/org/ow2/asm/asm-tree/9.6/asm-tree-9.6.jar + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/org/ow2/asm/asm-util/9.6/asm-util-9.6.jar + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/net/fabricmc/fabric-loader/0.14.23/fabric-loader-0.14.23.jar + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/com/mojang/minecraft/1.1/minecraft-1.1-client.jar + +Native libraries: + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/net/java/jinput/jinput-platform/2.0.5/jinput-platform-2.0.5-natives-windows.jar + C:/Users/********/AppData/Roaming/PrismLauncher/libraries/org/lwjgl/lwjgl/lwjgl-platform/2.9.0/lwjgl-platform-2.9.0-natives-windows.jar + +Mods: + [✔] optifabric-2.2.0+1.0-1.2 + [✔] OptiFine_1.1_HD_D6 + +Params: + --gameDir C:/Users/********/AppData/Roaming/PrismLauncher/instances/1.1/.minecraft --assetsDir C:/Users/********/AppData/Roaming/PrismLauncher/instances/1.1/.minecraft/resources + +Window size: 854 x 480 + +Launcher: standard + +Java major version is incompatible. Things might break. +Java Arguments: +[-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump, -Xms2048m, -Xmx2048m, -Duser.language=en] + + +Minecraft process ID: 15060 + + +[17:19:12] [INFO] [FabricLoader/GameProvider]: Loading Minecraft 1.1 with Fabric Loader 0.14.23 +[17:19:12] [INFO] [FabricLoader/GameRemap]: Fabric is preparing JARs on first launch, this may take a few seconds... +[17:19:14] [INFO] [FabricLoader/]: Loading 11 mods: + - fabricloader 0.14.23 + - java 22 + - minecraft 1.1 + - optifabric 2.2.0+1.0-1.2 + |-- commons-codec_commons-codec 1.15 + |-- commons-io_commons-io 2.11.0 + |-- mm 2.3.2 + |-- org_apache_commons_commons-lang3 3.12.0 + |-- org_slf4j_slf4j-api 1.7.30 + |-- org_slf4j_slf4j-simple 1.7.30 + \-- org_zeroturnaround_zt-zip 1.14 +[17:19:14] [INFO] [FabricLoader/Mixin]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=file:/C:/Users/********/AppData/Roaming/PrismLauncher/libraries/net/fabricmc/sponge-mixin/0.12.5+mixin.0.8.5/sponge-mixin-0.12.5+mixin.0.8.5.jar Service=Knot/Fabric Env=CLIENT +Optifabric is still using the traditional Early Riser initialisation +jar entry: null +jar entry: Config.class +Setting up optifine for the first time, this may take a few seconds. +De-Volderfiying jar +Building lambada fix mappings +Remapping optifine with fixed lambada names +[17:19:16] [ERROR] [FabricLoader/Mixin]: Error encountered during mixin config postInit step 'mixins.mm.json' from mod 'mm': Failed to setup optifine +java.lang.RuntimeException: Failed to setup optifine + at me.modmuss50.optifabric.mod.OptifabricSetup.run(OptifabricSetup.java:42) + at com.chocohead.mm.Plugin.getMixins(Plugin.java:346) + at org.spongepowered.asm.mixin.transformer.PluginHandle.getMixins(PluginHandle.java:128) + at org.spongepowered.asm.mixin.transformer.MixinConfig.postInitialise(MixinConfig.java:796) + at org.spongepowered.asm.mixin.transformer.MixinProcessor.prepareConfigs(MixinProcessor.java:568) + at org.spongepowered.asm.mixin.transformer.MixinProcessor.select(MixinProcessor.java:462) + at org.spongepowered.asm.mixin.transformer.MixinProcessor.checkSelect(MixinProcessor.java:438) + at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:290) + at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:234) + at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClassBytes(MixinTransformer.java:202) + at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.getPostMixinClassByteArray(KnotClassDelegate.java:422) + at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.tryLoadClass(KnotClassDelegate.java:323) + at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.loadClass(KnotClassDelegate.java:218) + at net.fabricmc.loader.impl.launch.knot.KnotClassLoader.loadClass(KnotClassLoader.java:119) + at java.base/java.lang.ClassLoader.loadClass(Unknown Source) + at net.fabricmc.loader.impl.game.minecraft.applet.AppletLauncher.(AppletLauncher.java:68) + at net.fabricmc.loader.impl.game.minecraft.applet.AppletFrame.launch(AppletFrame.java:108) + at net.fabricmc.loader.impl.game.minecraft.applet.AppletMain.run(AppletMain.java:44) + at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source) + at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source) + at java.desktop/java.awt.EventQueue$4.run(Unknown Source) + at java.desktop/java.awt.EventQueue$4.run(Unknown Source) + at java.base/java.security.AccessController.doPrivileged(Unknown Source) + at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) + at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source) + at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) + at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) + at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) + at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) + at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) + at java.desktop/java.awt.EventDispatchThread.run(Unknown Source) +Caused by: java.lang.RuntimeException: Failed to remap jar + at me.modmuss50.optifabric.patcher.RemapUtils.mapJar(RemapUtils.java:38) + at me.modmuss50.optifabric.mod.OptifineSetup.getRuntime(OptifineSetup.java:141) + at me.modmuss50.optifabric.mod.OptifabricSetup.run(OptifabricSetup.java:28) + ... 30 more +Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 + at net.fabricmc.tinyremapper.TinyRemapper.waitForAll(TinyRemapper.java:1170) + at net.fabricmc.tinyremapper.TinyRemapper.apply(TinyRemapper.java:912) + at net.fabricmc.tinyremapper.TinyRemapper.apply(TinyRemapper.java:872) + at me.modmuss50.optifabric.patcher.RemapUtils.mapJar(RemapUtils.java:33) + ... 32 more +Caused by: java.util.concurrent.ExecutionException: java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 + at java.base/De-Volderfiying jar +java.util.concurrent.FutureTask.report(Unknown Source) + at java.base/java.util.concurrent.FutureTask.get(Unknown Source) + at net.fabricmc.tinyremapper.TinyRemapper.waitForAll(TinyRemapper.java:1167) + ... 35 more +Caused by: java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 + at java.base/jdk.internal.util.Preconditions$1.apply(Unknown Source) + at java.base/jdk.internal.util.Preconditions$1.apply(Unknown Source) + at java.base/jdk.internal.util.Preconditions$4.apply(Unknown Source) + at java.base/jdk.internal.util.Preconditions$4.apply(Unknown Source) + at java.base/jdk.internal.util.Preconditions.outOfBounds(Unknown Source) + at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Unknown Source) + at java.base/jdk.internal.util.Preconditions.checkIndex(Unknown Source) + at java.base/java.lang.String.checkIndex(Unknown Source) + at java.base/java.lang.StringLatin1.charAt(Unknown Source) + at java.base/java.lang.String.charAt(Unknown Source) + at org.objectweb.asm.signature.SignatureReader.parseType(SignatureReader.java:190) + at org.objectweb.asm.signature.SignatureReader.accept(SignatureReader.java:122) + at org.objectweb.asm.commons.Remapper.mapSignature(Remapper.java:215) + at org.objectweb.asm.commons.ClassRemapper.visit(ClassRemapper.java:106) + at net.fabricmc.tinyremapper.VisitTrackingClassRemapper.visit(VisitTrackingClassRemapper.java:40) + at net.fabricmc.tinyremapper.AsmClassRemapper.visit(AsmClassRemapper.java:80) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:570) + at org.objectweb.asm.ClassReader.accept(ClassReader.java:425) + at net.fabricmc.tinyremapper.TinyRemapper.apply(TinyRemapper.java:1077) + at net.fabricmc.tinyremapper.TinyRemapper.lambda$apply$5(TinyRemapper.java:908) + at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) + at java.base/java.util.concurrent.FutureTask.run(Unknown Source) + at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) + at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) + at java.base/java.lang.Thread.run(Unknown Source) +27 achievements +174 recipes +[MM] Definitely not up to no good +Setting user: tildejustin, - +Oct 23, 2023 5:19:19 PM net.java.games.input.DefaultControllerEnvironment getControllers +WARNING: Found unknown Windows version: Windows 11 +Oct 23, 2023 5:19:19 PM net.java.games.input.DefaultControllerEnvironment getControllers +INFO: Attempting to use default windows plug-in. +Oct 23, 2023 5:19:19 PM net.java.games.input.DefaultControllerEnvironment getControllers +INFO: Loading: net.java.games.input.DirectAndRawInputEnvironmentPlugin +Oct 23, 2023 5:19:19 PM net.java.games.input.ControllerEnvironment log +INFO: Failed to initialize device HIDI2C Device because of: java.io.IOException: Failed to acquire device (8007001e) +Starting up SoundSystem... +Initializing LWJGL OpenAL + (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org) +OpenAL initialized. +An Optifabric error has occurred +Failed to load optifine, check the log for more info + Failed to remap jar +Failed to add pack.mcmeta +Failed to add READ_ME_I_AM_VERY_IMPORTANT +java.io.FileNotFoundException: http://s3.amazonaws.com/MinecraftResources/ + at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source) + at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) + at java.base/java.net.URL.openStream(Unknown Source) + at net.minecraft.unmapped.C_9029783.run(C_9029783.java:28) +An Optifabric error has occurred +Failed to load optifine, check the log for more info + Failed to remap jar +Stopping! +SoundSystem shutting down... + Author: Paul Lamb, www.paulscode.com +Process exited with code 0. diff --git a/readme.md b/readme.md index 8541f943..1aff5372 100644 --- a/readme.md +++ b/readme.md @@ -1,72 +1,40 @@ -# OptiFabric +## Legacy Optifabric -__Note:__ This project is not related or supported by either Fabric or Optifine. +Optifabric for Legacy Fabric (1.3-1.13.2) and Ornithe (1.0-1.13.2) -__Note:__ This project does not contain Optifine, you must download it separately! +based on the work of [RedLime's OptiFabric-Pre1.14](https://github.com/RedLime/OptiFabric-Pre1.14), a fork of [hYdos's OptiFabric 1.8.9](https://github.com/hYdos/OptiFabric) which +in turn is a derivative of [modmuss' original OptiFabric](https://github.com/modmuss50/OptiFabric) -## Installing +## installing -After installing fabric for 1.15.2, you will need to place the OptiFabric mod jar as well as the optifine installer in the mods folder. +this mod requires an optifine jar in the mods folder alongside a release of optifabric. for 1.7.2 and onwards this can be sourced +from [OptiFine's official website](https://optifine.net/downloads), and older versions these can be retrieved either +from [SpeedyCube64's Pre-1.9 Optifine Archive](https://github.com/speedycube64/Complete_OptiFine_Archive_Pre_1.9) or on +the [OptiFine history thread](https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/1286605-b1-4-1-9-optifine-history). -Fabric Loader should be the latest version from the [Fabric Website](https://fabricmc.net/use/) +## how it works -If you need more help you can read a more detailed guide [here](https://github.com/modmuss50/OptiFabric/wiki/Install-Tutorial) +this mod uses [Minecraft-Java-Edition-Speedrunning/fabric-asm](https://github.com/Minecraft-Java-Edition-Speedrunning/fabric-asm), a derivative +of [Cat Core's Fabric-ASM/no-guava](https://github.com/thecatcore/Fabric-ASM/tree/no-guava) which itself is an updated version +of [Chocohead's fabric-asm](https://github.com/Chocohead/Fabric-ASM). fabric asm allows more extreme asm modification and the fork used has no dependency on guava or apache +commons, which older minecraft versions don't provide. +### steps -## Links +1. the mod looks for an optifine installer or mod jar or zip in the current mods folder +2. if it finds an installer jar it runs the extract task in its own throwaway classloader +3. the optifine mod jar is a set of classes that need to replace the ones that minecraft provides +4. optifine's replacement classes change the name of some lambda methods, so it take a good guess at the old name (using the original minecraft jar) +5. remap optifine to intermediary +6. move the patched classes out as they won't do much good on the classpath twice +7. add optifine to the classpath +8. register the patching tweaker for every class that needs replacing +9. replace the target class with the class that was extracted, also do some more fixes to it, and make it public (due to access issues) +10. hope it works -### [OptiFabric Downloads](https://minecraft.curseforge.com/projects/optifabric) +## notes -### [Optifine Download](https://optifine.net/downloads) - -## Issues - -If you happen to find an issue and you believe it is to do with OptiFabric and not Optifine or a mod please open an issue [here](https://github.com/modmuss50/OptiFabric/issues) - - -## For Mod Devs - -Add the following to your build.gradle - -```groovy -repositories { - maven { url 'https://jitpack.io' } -} - -dependencies { - // replace OptiFabric: with latest version on https://www.curseforge.com/minecraft/mc-mods/optifabric/files that fits your MC version - modCompile 'com.github.modmuss50:OptiFabric:1.0.0-beta8' - - //Deps required for optifabric - compile 'org.zeroturnaround:zt-zip:1.14' -} -``` - -Put the standard Optifine jar in /run/mods - -Class export can be enabled using the following VM Option, this will extract the overwritten classes to the .optifine folder, useful for debugging. - -`-Doptifabric.extract=true` - -## Screenshots - -Feel free to open a PR with more screenshots. - -![](https://ss.modmuss50.me/javaw_2019-05-22_20-36-25.jpg) - -![](https://ss.modmuss50.me/javaw_2019-05-22_19-49-41.jpg) - -## How it works - -This would not have been possible without Chocohead's [Fabric-ASM](https://github.com/Chocohead/Fabric-ASM). - -1. The mod looks for an optifine installer or mod jar in the current mods folder -2. If it finds an installer jar it runs the extract task in its own throwaway classloader. -3. The optifine mod jar is a set of classes that need to replace the ones that minecraft provides. -4. Optifine's replacement classes change the name of some lambda methods, so I take a good guess at the old name (using the original minecraft jar). -5. Remap optifine to intermediary (or yarn in development) -6. Move the patched classes out as they wont do much good on the classpath twice -7. Add optifine to the classpath -8. Register the patching tweaker for every class that needs replacing -9. Replace the target class with the class that was extracted, also do some more fixes to it, and make it public (due to access issues). -10. Hope it works +- this does not work for any optifine releases for minecraft 1.1 except for the optifine light edition due to some method signature crash ([log](optifabric-hd-1.1-crash.log)) + outside my control +- this mod does not work in dev or named environments, if someone fixes that do make a pull request +- the accessWideners are created based on the output of tiny remapper's checkPackageAccess option, but they cannot ever be 100% complete. if you have a crash that has to do with and invalid access, report it and it may be able to be fixed. \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index e98b71da..fa691448 100644 --- a/settings.gradle +++ b/settings.gradle @@ -7,3 +7,13 @@ pluginManagement { mavenLocal() } } + +// include "1.0-1.2.5-ornithe" +include "1.3-1.5.2" +// include "1.3-1.5.2-ornithe" +include "1.6-1.7.10" +// include "1.6-1.7.10-ornithe" +include "1.8-1.12.2" +// include "1.8-1.12.2-ornithe" +include "1.13.2" +// include "1.13-1.13.2-ornithe" diff --git a/src/main/java/me/modmuss50/optifabric/mod/OptifabricLoadGuard.java b/src/main/java/me/modmuss50/optifabric/mod/OptifabricLoadGuard.java index 95f5b9e5..c0c97dcf 100644 --- a/src/main/java/me/modmuss50/optifabric/mod/OptifabricLoadGuard.java +++ b/src/main/java/me/modmuss50/optifabric/mod/OptifabricLoadGuard.java @@ -10,4 +10,4 @@ public void onPreLaunch() { //There is good precedent as this as a solution to the problem, first found here: //https://github.com/ReplayMod/ReplayMod/commit/27edfcb4f3cd0eac0c7fb24e87ee3fa67324ab0a } -} \ No newline at end of file +} diff --git a/src/main/java/me/modmuss50/optifabric/mod/OptifabricSetup.java b/src/main/java/me/modmuss50/optifabric/mod/OptifabricSetup.java index 1dbdcfee..7ada32b2 100644 --- a/src/main/java/me/modmuss50/optifabric/mod/OptifabricSetup.java +++ b/src/main/java/me/modmuss50/optifabric/mod/OptifabricSetup.java @@ -5,7 +5,9 @@ import me.modmuss50.optifabric.patcher.ClassCache; import net.fabricmc.loader.api.*; import org.spongepowered.asm.mixin.Mixins; +import org.spongepowered.asm.service.*; +import java.io.*; import java.nio.file.Path; import java.util.List; import java.util.stream.Collectors; @@ -14,6 +16,7 @@ public class OptifabricSetup implements Runnable { public static final String OPTIFABRIC_INCOMPATIBLE = "optifabric:incompatible"; public static Path optifineRuntimeJar = null; + private static final String optifineMixinConfiguration = "optifabric.optifine.mixins.json"; // this is called early on to allow us to get the transformers in before minecraft starts @Override @@ -24,7 +27,7 @@ public void run() { try { Pair runtime = new OptifineSetup().getRuntime(); - // add the optifine jar to the classpath, as + // add the optifine jar without classes to be replaced to the classpath ClassTinkerers.addURL(runtime.left().toUri().toURL()); OptifineInjector injector = new OptifineInjector(runtime.right()); @@ -38,7 +41,9 @@ public void run() { } throw new RuntimeException("Failed to setup optifine", e); } - Mixins.addConfiguration("optifabric.optifine.mixins.json"); + if (hasOptifineMixins()) { + Mixins.addConfiguration(optifineMixinConfiguration); + } } private boolean validateMods() { @@ -58,4 +63,13 @@ private boolean validateMods() { } return true; } + + private static boolean hasOptifineMixins() { + IMixinService service = MixinService.getService(); + try (InputStream resource = service.getResourceAsStream(optifineMixinConfiguration)) { + return resource != null; + } catch (IOException e) { + return false; + } + } } diff --git a/src/main/java/me/modmuss50/optifabric/mod/OptifineSetup.java b/src/main/java/me/modmuss50/optifabric/mod/OptifineSetup.java index 2c197a72..0bfab4a4 100644 --- a/src/main/java/me/modmuss50/optifabric/mod/OptifineSetup.java +++ b/src/main/java/me/modmuss50/optifabric/mod/OptifineSetup.java @@ -6,7 +6,7 @@ import net.fabricmc.loader.api.*; import net.fabricmc.loader.impl.launch.FabricLauncherBase; import net.fabricmc.mappingio.MappingReader; -import net.fabricmc.mappingio.tree.MemoryMappingTree; +import net.fabricmc.mappingio.tree.*; import net.fabricmc.tinyremapper.IMappingProvider; import java.io.*; @@ -137,6 +137,7 @@ public Pair getRuntime() throws IOException, NoSuchAlgorithmEx Files.deleteIfExists(optifineModJar); } + // TODO: for extract, make a remapped jar containing both class sets instead of individual files if (Boolean.parseBoolean(System.getProperty("optifabric.extract", "false"))) { System.out.println("extracting optifine classes"); Path optifineClasses = versionDir.resolve("optifine-classes"); @@ -168,7 +169,6 @@ private void remapOptifine(Path input, Path remappedJar) throws IOException { String namespace = FabricLoader.getInstance().getMappingResolver().getCurrentRuntimeNamespace(); System.out.println("remapping optifine to " + namespace); List mcLibs = this.getLibs(); - System.out.println(mcLibs); mcLibs.add(this.getMinecraftJar()); RemapUtils.mapJar(remappedJar, input, this.createMappings("official", namespace), mcLibs); } @@ -180,7 +180,27 @@ IMappingProvider createMappings(@SuppressWarnings("SameParameterValue") String f assert mappings != null; MappingReader.read(new InputStreamReader(mappings), tree); } - return TinyRemapperMappingsHelper.create(tree, from, to); + int fromId = tree.getNamespaceId(from); + return (out) -> { + for (MappingTree.ClassMapping classDef : tree.getClasses()) { + String className = classDef.getName(from); + out.acceptClass(className, classDef.getName(to)); + + for (MappingTree.FieldMapping field : classDef.getFields()) { + out.acceptField(new IMappingProvider.Member(className, field.getName(from), field.getDesc(fromId)), field.getName(to)); + } + + for (MappingTree.MethodMapping method : classDef.getMethods()) { + // cwv.a(II)Z now overrides ayl.a(II)Z, need to remove the mapping + // for 1.13.2 + if ("cwv".equals(className) && "a".equals(method.getName(from)) && "(II)Z".equals(method.getDesc(fromId))) { + continue; + } + out.acceptMethod(new IMappingProvider.Member(className, method.getName(from), method.getDesc(fromId)), method.getName(to)); + } + } + }; + // return TinyRemapperMappingsHelper.create(tree, from, to); } List getLibs() { diff --git a/src/main/java/me/modmuss50/optifabric/mod/OptifineVersion.java b/src/main/java/me/modmuss50/optifabric/mod/OptifineVersion.java index d10b3cac..6d29d04f 100644 --- a/src/main/java/me/modmuss50/optifabric/mod/OptifineVersion.java +++ b/src/main/java/me/modmuss50/optifabric/mod/OptifineVersion.java @@ -59,7 +59,10 @@ private static JarType getJarType(Path file) { try (JarFile jarFile = new JarFile(file.toFile())) { JarEntry jarEntry = jarFile.getJarEntry("Config.class"); if (jarEntry == null) { - jarEntry = jarFile.getJarEntry("VersionThread.class"); + jarEntry = jarFile.getJarEntry("VersionThread.class" /* optifine light and pre-1.3? */); + } + if (jarEntry == null) { + jarEntry = jarFile.getJarEntry("net/optifine/Config.class" /* 1.13+ */); } System.out.println("jar entry: " + jarEntry); if (jarEntry == null) { diff --git a/src/main/java/me/modmuss50/optifabric/mod/TinyRemapperPreload.java b/src/main/java/me/modmuss50/optifabric/mod/TinyRemapperPreload.java index 1afd478e..a77e9dd7 100644 --- a/src/main/java/me/modmuss50/optifabric/mod/TinyRemapperPreload.java +++ b/src/main/java/me/modmuss50/optifabric/mod/TinyRemapperPreload.java @@ -1,6 +1,9 @@ package me.modmuss50.optifabric.mod; import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.impl.launch.FabricLauncherBase; +import net.fabricmc.tinyremapper.InputTag; +import net.fabricmc.tinyremapper.OutputConsumerPath.Builder; import java.util.Arrays; @@ -74,7 +77,7 @@ public static void load() { "net.fabricmc.tinyremapper.api.TrMember" ).forEach(clazz -> { try { - Class.forName(clazz, false, FabricLoader.class.getClassLoader()); + Class.forName(clazz, false, FabricLauncherBase.getLauncher().getTargetClassLoader()); } catch (ClassNotFoundException e) { System.out.println("failed to find " + clazz); } diff --git a/src/main/java/me/modmuss50/optifabric/patcher/RemapUtils.java b/src/main/java/me/modmuss50/optifabric/patcher/RemapUtils.java index 6feb02f0..a59778b5 100644 --- a/src/main/java/me/modmuss50/optifabric/patcher/RemapUtils.java +++ b/src/main/java/me/modmuss50/optifabric/patcher/RemapUtils.java @@ -17,6 +17,7 @@ public static void mapJar(Path output, Path input, IMappingProvider mappings, Li .withMappings(mappings) .renameInvalidLocals(true) .rebuildSourceFilenames(true) + .checkPackageAccess(true) .fixPackageAccess(true) .build(); try { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index efe997c3..3d19454c 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -16,9 +16,6 @@ "sources": "https://github.com/tildejustin/optifabric", "issues": "https://github.com/tildejustin/optifabric/issues" }, - "mixins": [ - "optifabric.mixins.json" - ], "license": "MPL-2.0", "icon": "assets/optifabric/icon.png", "environment": "client", @@ -31,8 +28,7 @@ ] }, "depends": { - "fabricloader": ">=0.14.0", - "minecraft": ">=1.8 <1.13" - }, - "accessWidener": "optifabric.accesswidener" + "fabricloader": ">=0.14", + "minecraft": ">=1.0.0 <=1.13.2" + } } diff --git a/src/main/resources/optifabric.accesswidener b/src/main/resources/optifabric.accesswidener deleted file mode 100644 index ce87f2d2..00000000 --- a/src/main/resources/optifabric.accesswidener +++ /dev/null @@ -1,7 +0,0 @@ -accessWidener v2 named -accessible field net/minecraft/client/gui/widget/ButtonWidget width I -accessible field net/minecraft/client/gui/widget/ButtonWidget height I -accessible method net/minecraft/util/Language getInstance ()Lnet/minecraft/util/Language; -accessible method net/minecraft/block/Block setOpacity (I)Lnet/minecraft/block/Block; -accessible field net/minecraft/entity/LivingEntity despawnCounter I -accessible field net/minecraft/resource/AbstractFileResourcePack base Ljava/io/File;