User Tools

Site Tools


tutorial:mixin_injects

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
tutorial:mixin_injects [2020/02/07 01:48] draylartutorial:mixin_injects [2020/02/07 01:58] draylar
Line 24: Line 24:
  
 === Returning & Cancelling from Inject === === Returning & Cancelling from Inject ===
-To cancel or return early inside a method, use ''CallbackInfo#cancel'' or ''CallbackInfoReturnable<T>#setReturnValue(T)''. In both instances, ''cancellable'' will have to be set to true in the inject annotation:+To cancel or return early inside a method, use ''CallbackInfo#cancel'' or ''CallbackInfoReturnable<T>#setReturnValue(T)''. Note that ''cancel'' does not have to be called after ''setReturnValue''. In both instances, ''cancellable'' will have to be set to true in the inject annotation:
 <code java> <code java>
 @Inject(method = "...", at = @At("..."), cancellable = true) @Inject(method = "...", at = @At("..."), cancellable = true)
Line 30: Line 30:
  
  
 +=== Injecting into Constructors ===
 +To inject into a constructor, use ''<init>()V'' as the method target, with ''()'' containing the constructor argument descriptors. When injecting into constructors, ''@At'' must be set to either ''TAIL'' or ''RETURN''.
  
 ===== Practical Example ===== ===== Practical Example =====
tutorial/mixin_injects.txt · Last modified: 2022/08/05 19:19 by clomclem