diff --git a/docs/apidoc/index.md b/docs/apidoc/index.md index e88d90f..8f1d0dd 100644 --- a/docs/apidoc/index.md +++ b/docs/apidoc/index.md @@ -148,6 +148,10 @@ For example, take the method `setRenderViewEntity()` on `ModAPI.mcinstance`. Ins var entityIndex = 1; //Index of the entity to look for. 0 means first, which is usually the player, so 1 is usually a natural entity. ModAPI.mc.setRenderViewEntity(ModAPI.world.loadedEntityList.get(entityIndex).getRef()); ``` +Note that an entry for `getRef` will not appear from `Object.keys` and similar web APIs. + +## Checking if an object is a proxy +All proxied objects have a property `isModProxy` which is equal to true. Note that an entry for `isModProxy` will not appear from `Object.keys` and similar web APIs. ## Corrective Proxies By default, accessing a global like `ModAPI.player` will return a proxy to the original player that removes $ prefixes, as well as making instance methods callable. TeaVM has a quirk where it adds numerical suffixes to some properties. For example `ModAPI.player.inGround0` instead of `ModAPI.player.inGround`. As this is a large issue due to these suffixes changing for every eaglercraft update, you can now bypass this by obtaining a corrective version of `ModAPI.player`, using `ModAPI.player.getCorrective()`. diff --git a/docs/apidoc/utils.md b/docs/apidoc/utils.md index 0d3a635..054469e 100644 --- a/docs/apidoc/utils.md +++ b/docs/apidoc/utils.md @@ -57,4 +57,28 @@ Methods: }); console.log(multiply(2, 3)); //Logs 6 - ``` \ No newline at end of file + ``` +- `ModAPI.util.modifyFunction(fn: Function, patcherFunction: Function) : string` + - Returns a modifies version of a function, where the patcher function can be used to modify the contents of a function. Example: + ```javascript + function add(a, b) { + return a + b; + } + var multiply = ModAPI.util.modifyFunction(add, (code)=>{ + return code.replaceAll("a + b", "a * b"); + }); + console.log(multiply(2, 3)); + //Logs 6 + ``` +- `ModAPI.util.getIdFromItem(item: Item) : number` + - Gets the ID of an item +- `ModAPI.util.getItemById(id: number) : Item` + - Gets an item by it's ID +- `ModAPI.util.getItemFromBlock(block: Block) : ItemBlock` + - Gets an item from a block. +- `ModAPI.util.getIdFromBlock(block: Block) : number` + - Gets the ID of a block +- `ModAPI.util.getBlockById(id: number) : Block` + - Gets a block by it's ID +- `ModAPI.util.getBlockFromItem(item: Item) : Block` + - Gets a block from an ItemBlock instance. \ No newline at end of file diff --git a/index.html b/index.html index 32c56ac..ffbb2b7 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@
-