Mixins to net.minecraft.client.main.Main break ReplayModNonMMLauncher
comp500 opened this issue ยท 3 comments
ReplayModNonMMLauncher
seems to call Mixins.addConfiguration
instead of returning the mixin configurations from getMixins
, so the mixin configurations aren't loaded if the first class loaded has a mixin applied.
In this case, my mod Screenshot to Clipboard mixes into net.minecraft.client.main.Main
which is the first class loaded, so the configurations don't get loaded, resulting in the following crash: https://paste.ee/p/KKoHL
This occurs with Replay Mod 1.16.1-2.4.2, Fabric API 0.17.0+build.386-1.16.1 and Screenshot to Clipboard 1.0.6.
Ah right, that makes sense. The reason Screenshot to Clipboard mixes into Main is to re-enable AWT when not running on macOS, and this is the earliest point it can do so as Minecraft puts AWT into headless mode in a main static (it uses AWT as GLFW doesn't support copying images, only text, and implementing such copying cross-platform with JNI is rather more difficult).
It seems that this issue can be fixed by making the first class to be loaded through Mixin bytecode transformation a class that has no mixins applied, and this can be accomplished by adding a dummy preLaunch entrypoint class as follows:
public class DummyPreLaunch implements PreLaunchEntrypoint {
@Override
public void onPreLaunch() {
// Do nothing
}
}
I can add this to Screenshot to Clipboard, but it might be a good idea to add it to Replay Mod instead?
Oh, I totally forgot about the preLaunch entrypoint existing. You're right, that should fix it. Thank you very much.
I'll be including one in the next version. Don't think Screenshot to Clipboard should have to change anything cause it's not the one relying on Mixin's odd behavior here.
That's intentional. We need our Mixins to be loaded after Optifabric has done its setup, so directly returning them from getMixins
won't do (and doesn't do the same thing as addConfiguration anyway).
See gnembon/fabric-carpet#341.
I've looked into it a few times and afaict that's no other way to do that. So, short of fixing chain-loading in Mixin (which I'm not opposed to, just don't have the time to do it myself), the easiest way around this is to not mixin into Main (that doesn't sound like it'd be necessary to screenshot to clipboard).