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 revision
Previous revision
tutorial:mixin_injects [2025/12/08 17:43] – Edit example where WrapOp is preferrable to have it capture an expression rather than just a local, suggested by EarthComputer gauntreclusetutorial:mixin_injects [2025/12/15 16:52] (current) – Added an extra bracket to show that it has to be inside @At more clearly mcgambingpro
Line 39: Line 39:
 } }
 </code> </code>
-if we wished to inject right after the ''slap'' call, we could use a [[#shifting|Shift]] to inject after the call with ''@Inject''. However, if we needed to also get the ''force'' variable, it would be instead preferable to use a ''@WrapOperation'' to get the ''force / haykam.resistance'' parameter's value without needing to use ''@Local'' on ''force'' to then recalculate it.\\+if we wished to inject right after the ''slap'' call, we could use a [[#shifting|Shift]] to inject after the call with ''@Inject''. However, if we needed to also get the ''force / haykam.resistance'' value, it would be instead preferable to use a ''@WrapOperation'' to get it without needing to use ''@Local'' on ''force'' to then recalculate it.\\
 For the sake of showing how to appropriately add our new operations after the original method call outside of void returns, we'll say ''slap'' has a ''boolean'' return value. For the sake of showing how to appropriately add our new operations after the original method call outside of void returns, we'll say ''slap'' has a ''boolean'' return value.
 <code java> <code java>
Line 134: Line 134:
 The only common form of shifting comes in the form of using ''shift = At.Shift.AFTER'' within the ''@At''. This shifts the injection point to after the target. The syntax for shifting looks as follows: The only common form of shifting comes in the form of using ''shift = At.Shift.AFTER'' within the ''@At''. This shifts the injection point to after the target. The syntax for shifting looks as follows:
 <code java> <code java>
-@Inject(method = "...", at = @At(value = "...", target = "...", shift = At.Shift.AFTER)+@Inject(method = "...", at = @At(value = "...", target = "...", shift = At.Shift.AFTER))
 </code> </code>
tutorial/mixin_injects.1765215823.txt.gz · Last modified: 2025/12/08 17:43 by gauntrecluse