Repository navigation
Redirect Method Call
This page is about
@RedirectMethodCallredirects specifically. You should make sure to read the general page about Redirects before it.
The @RedirectMethodCall annotation is one of the more versatile redirects. As the game primarily uses methods instead of public field accessors, method call redirects can be used in a variety of places.
This type of redirect can intercept a method call within a host method. If your target method contains a call to Global.getSector().getPlayerFleet(), then both getSector() and getPlayerFleet are valid intercept targets.
Use cases for this type of redirect include:
- Replacing the input arguments going into a method call
- Replacing the output of a method call
- Running your code right before or after a method call
- Skipping the original logic of the method call
Method call redirects require the MethodCallContext type for their patch handler's context parameter.
The method call redirect's context parameter provides the following methods:
-
Object call(): Calls the next redirect layer -
Object call(Object... args): Calls the next redirect layer, overwriting the passed-in args -
void setResult(Object result): Sets the result value for this layer. If the redirect call has no return type, usenull. -
Object getCallArg(int index)/Object[] getCallArgs(): Retrieves arguments passed down to the redirected method call. -
void setCallArg(int index, Object newValue): Replaces a specific argument from the redirect call. It will only be used when using the no-arg version of.call. -
Object getArg(int index): Retrieves arguments passed down to the host method. - All other methods that are available across all patch types, i.e.
getData()and the reflection utilities.
- Home
- Introduction to Patchlib
- Patch Types
- Working with obfuscated code
- Example Patches
- Other utilities
- Patching with Kotlin
- Developer Documentation