ModifyReturnValue¶
Info
For a more in-depth explanation, see the MixinExtra's Wiki.
Lets you easily modify the return value of a function.
@ModifyReturnValue(method = "foo", at = @At(value = "RETURN"))
private int getFoo(int original) {
return original + 1; // returns the original value +1
}
If a method has multiple returns, you can specify which return to target with an ordinal, or the last one with "value = "TAIL". That said, ordinals are brittle, and can usually be replaced with a slice or with an @Expression.
ModifyReturnValue should always be used over cir.setReturnValue(cir.getReturnValue()) patterns from Injects.