mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-25 07:01:20 -09:00
23 lines
1.4 KiB
Markdown
23 lines
1.4 KiB
Markdown
## ModAPI.hooks
|
|
ModAPI.hooks is the global generated by actual code.
|
|
It has quite a few propeties, but most of them are just foundations for more user friendly parts of the ModAPI, so I won't explain them.
|
|
|
|
### Property: ModAPI.hooks.methods
|
|
`ModAPI.hooks.methods` is a String-to-method dictionary/object of every java method. This allows you to do pretty much whatever you want in terms of modifying and hooking into code.
|
|
|
|
- To replace a method with another, you can use:
|
|
- `ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("com.package.abc.MyClass", "myMethod")] = function () {}`
|
|
- To intercept inputs to a method, you can us
|
|
- ```javascript
|
|
var myMethodName = ModAPI.util.getMethodFromPackage("com.package.abc.MyClass", "myMethod");
|
|
const originalMethod = ModAPI.hooks.methods[myMethodName];
|
|
ModAPI.hooks.methods[myMethodName] = function (...args) {
|
|
//args is the array of arguments passed in.
|
|
//on an instance method, this first (args[0]) will almost always
|
|
//be $this, ie: the object the method is being run on
|
|
return originalMethod.apply(this, args);
|
|
}
|
|
```
|
|
|
|
### Property: ModAPI.hooks._teavm
|
|
`ModAPI.hooks._teavm` is usually only used for internal purposes, but it is basically a collection of every internal TeaVM method. Keep in mind that this only stores references (for performance reasons), so modifying and editing it's contents will not affect the way the game runs. |