CleanroomMC / MixinBooter

Allows any mixins that work on mods to work effortlessly. With a single class and an annotation. On 1.12.2.
GNU Lesser General Public License v2.1
50 stars 17 forks source link

Not possible to reference private inner classes in method signatures #44

Open NotMyWing opened 1 year ago

NotMyWing commented 1 year ago

It's currently impossible to reference instances of private inner classes (specifically, of other mods, which can't traditionally be access transformed) in method signatures. Coercing arguments also doesn't seem to be possible, as Mixin strictly expects the signature to be A$B, so defining the argument as Object fails at runtime. @Local expects A$B as well. This leaves no options for targeting the instance.

Example class:

class A {
  method(B b);

  static class B {}
}

Example mixin:

interface IExtendedB {}

@Mixin(B.class)
class mB implements IExtendedB {}

@Mixin(A.class)
class mA {
  @Inject(method = "method", ...)
  public void injection(A.B b, CallbackInfo ci) {} // oops! fails at compile-time
  public void injection(CallbackInfo ci, @Local IExtendedB b) {} // oops! fails at runtime
  public void injection(CallbackInfo ci, @Local Object b) {} // oops! failed to validate at runtime
}
NotMyWing commented 1 year ago

Update: I might be an idiot, but @Coerce finally worked in my environment RIGHT AFTER I have submitted this.

public void injection(@Coerce Object b, ...)

Feel free to close this or do as you see fit.