-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Convert Forge's CoreMods to Mixins, deprecate JS CoreMods #10177
base: 1.21.x
Are you sure you want to change the base?
[RFC] Convert Forge's CoreMods to Mixins, deprecate JS CoreMods #10177
Conversation
- Minecraft Forge can now ship its own Mixins. - `ForgeMixinPlugin` is used as both the connector and plugin. - The plugin can be very useful if we need to do manual ASM for any unhinged reason. - `minecraftforge.mixins.json` acts as the Mixin counterpart to `coremods.json`, giving all the necessary info for Forge's mixins.
@Redirect( | ||
method = { | ||
"<init>(Lnet/minecraft/world/effect/MobEffectInstance;)V", | ||
"getParticleOptions()Lnet/minecraft/core/particles/ParticleOptions;", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way that these strings can be encoded better to provide better error when things change?
@MethodRef("<init>", args = { MobEffectInstance.class }, ret = Void.class)
or something?
Perhaps a build script task that verifies that we have all the expected targets?
We already have the code to generated the json that feeds the existing coremod, can something be expanded to mixins?
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
As discussed on Discord, I will be taking a different approach to these larger-scale Mixins that require several classes in order to have the same functionality that the original CoreMods did. This will likely mean writing a tool that generates Mixin classes on Gradle build. Smaller-scale mixins, like for patches we make already through bin patch, are more suited to the way Mixins are currently written. |
It's time to kill CoreMods.
Background
Since the FML rewrite in 1.13, JS CoreMods have existed as a replacement to the previous Java-based CoreMods transformers that has existed in versions 1.12.2 and older. This was done to keep transformers within a sandbox where they couldn't cause unhinged early classloading issues and other nonsense. However, since 1.16 (and eventually 1.15), Forge has been shipping SpongePowered's Mixin as an alternative solution to transforming classes at runtime. It has since become the defacto "coremodding tool" and effectively supersedes CoreMods. Besides, if people really wanted to write ASM transformers in Java, they already can with ModLauncher services.
All that said, I have made this preliminary PR for a handful of reasons:
Migration to Mixins
With regards to migrating to Mixins, there are a few key points that need to be addressed.
Forge's Mixins
As of the creation of this PR, I have converted the existing CoreMods into Mixins.
Mixin Libraries
@WrapOperation
than@Redirect
since MixinExtras can chain injectors of the former properly).Note
MixinExtras can already be, and is already commonly, shadowed in with mods by using the JarJar system. It is not imperative that this is added to ForgeDev or UserDev, but would add to the convenience of modders.
Deprecation of CoreMods
As mentioned above, an additional purpose of moving Forge's CoreMods to Mixins is to incentivize the deprecation, and eventual removal, of the CoreMods framework. CoreMods's only purpose was to provide a method of creating ASM transformers within a sandbox, and it has ultimately failed at that goal considering the status of Mixin and the availability of ModLauncher transformer services.
So, we need to decide the following:
Note
Raw ASM transformers can still be created, with Mixin, by using a Mixin config plugin and overriding
postApply()
.Merge Process
Before this PR can be merged, the following must happen:
Disclaimers
Please note that, as of writing, this PR is still a work-in-progress and things about it may change, including the information in this PR description and the discussion surrounding it. Major testing still needs to done and discussions need to happen in order for this to go anywhere. There is no time limit, but I hope that this RFC PR is enough to start preparing for this change.
None of the changes in this PR will be backported to any versions before the merged version unless there are specific changes that can be which don't break compatibility, binary or otherwise.
Important
If you are a modder, you should not be using CoreMods or Mixins before attempting to use existing Forge APIs. You are more than welcome to write PRs that add your desired functionality to the mod loader.