SpongePowered / Mixin

Mixin is a trait/mixin and bytecode weaving framework for Java using ASM
MIT License
1.36k stars 185 forks source link

Add Global Grouping for Injections #312

Open gabizou opened 5 years ago

gabizou commented 5 years ago

On discovering the @Group annotation, I've attempted to do something where I'd consider it a good feature for two redirects to be required to succeed only in an exclusive or situation (vanilla having a method, and forge rewriting that method or adding a new method signature, eliminating the vanilla form).

Somewhat similar to https://github.com/SpongePowered/Mixin/issues/297

Summary of discussion with Mumfrey about this:

Essentially, given two classes:

@Mixin(Foo.class) 
public class MixinFoo {

  @Group(name = "com.example.fully.qualified:groupname")
  @Redirect(method = "foo", at= @At(value = "INVOKE", target ="fqm()V")
  private void vanillaMethod() { }
}

@Mixin(Foo.class)
public class com.example.fully.qualified.mod.MixinFoo {

  @Group(name = "com.example.fully.qualified:groupname")
  @Redirect(method = "foo", at = @At(value = "INVOKE", target = "fqm(I)V")
  private void modifiedMethod(int var) { }
}

It would suffice to say that the following requirements would be set:

Example of an existing setup with Group as this issue is intending: https://gist.github.com/gabizou/9a891cc8f68e1dc7506e9dce16571162

Mumfrey commented 5 years ago

Thanks for making this issue based on our discussion. I'm not going to add this to the 0.8 milestone but I'll start work on it immediately after.

gabizou commented 4 years ago

Just gonna comment to remind about the feature since 0.8 has been done, though there's other things that are likely being prioritized.

Mumfrey commented 4 years ago

Don't worry I haven't forgotten about it. I just haven't created a 0.9 milestone.