Skip to content

Commit

Permalink
suppress launchwrapper classloading failure
Browse files Browse the repository at this point in the history
  • Loading branch information
tildejustin committed Dec 11, 2023
1 parent 96ebff4 commit ecf33f7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<Class<?>> 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;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import me.modmuss50.optifabric.patcher.ClassCache;
import net.fabricmc.loader.api.*;
import net.fabricmc.loader.api.metadata.ModMetadata;
import org.spongepowered.asm.mixin.Mixins;

import java.io.File;
import java.util.*;
Expand Down Expand Up @@ -36,6 +37,7 @@ public void run() {
}
throw new RuntimeException("Failed to setup optifine", e);
}
Mixins.addConfiguration("optifabric.optifine.mixins.json");
}

private boolean validateMods() {
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/optifabric.optifine.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"required": true,
"package": "me.modmuss50.optifabric.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
"ReflectorClassMixin"
]
}

0 comments on commit ecf33f7

Please sign in to comment.