diff --git a/1.6-1.7.10/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java b/1.6-1.7.10/src/main/java/me/modmuss50/optifabric/mixin/ReflectorClassMixin.java index a6ee537e..b69b520f 100644 --- a/1.6-1.7.10/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,24 +4,42 @@ import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import java.lang.reflect.Field; + // suppresses some warnings in the logs @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) { + String targetClassName = this.getTargetClassName(); if (!this.checked) { // only check the target if it hasn't been done yet - String name = this.targetClassName.replaceAll("/", "."); + String name = targetClassName.replaceAll("/", "."); if (name.startsWith("net.minecraft.launchwrapper") || name.startsWith("net.minecraftforge") || "optifine.OptiFineClassTransformer".equals(name)) { this.checked = true; } } } + + @Unique + private String getTargetClassName() { + try { + Field targetClass = this.getClass().getDeclaredField("targetClassName"); + targetClass.setAccessible(true); + return (String) targetClass.get(this); + } catch (NoSuchFieldException | IllegalAccessException e) { + try { + // 1.7.2 behavior + Field targetClass = this.getClass().getDeclaredField("targetClassNames"); + targetClass.setAccessible(true); + return ((String[]) targetClass.get(this))[0]; + } catch (NoSuchFieldException | IllegalAccessException ex) { + throw new RuntimeException(ex); + } + } + } } diff --git a/gradle.properties b/gradle.properties index af9a1b22..9a6021ee 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ org.gradle.caching=false minecraft_version=1.3.2 target_version=1.3-1.13.2 yarn_build=533 -mod_version=2.3.0 +mod_version=2.3.1 archives_name=optifabric maven_group=me.modmuss50 fabric_loader_version=0.15.3