From 34607605a218a64cda5048d9572e1a1a554c215a Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Fri, 1 Nov 2024 15:33:14 +0800 Subject: [PATCH] Fix bad link, add function to manually regenerate bootstrap --- docs/apidoc/utils.md | 2 ++ docs/tutorials/comingsoon.md | 1 + postinit.js | 10 +++++++--- roadmap.txt | 5 ----- 4 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 docs/tutorials/comingsoon.md delete mode 100644 roadmap.txt diff --git a/docs/apidoc/utils.md b/docs/apidoc/utils.md index fa80f21..0d3a635 100644 --- a/docs/apidoc/utils.md +++ b/docs/apidoc/utils.md @@ -37,6 +37,8 @@ Methods: - `ModAPI.util.isCritical() : boolean` - Checks wether the thread is in a critical state. - When patching methods, it is good practice to allow the method to resume as usual if this is `true`, to avoid stack implosions. (yes, those are real) +- `ModAPI.util.bootstrap() : void` + - Regenerate proxies for ModAPI.items, .blocks, .materials, .enchantments - `ModAPI.util.createArray(class, jsArray) : Object[]` - Makes a java array from a class and a javascript array. - The class parameter can be retrieved via reflect: `ModAPI.reflect.getClassById("net.minecraft.util.BlockPos").class` diff --git a/docs/tutorials/comingsoon.md b/docs/tutorials/comingsoon.md new file mode 100644 index 0000000..8276d92 --- /dev/null +++ b/docs/tutorials/comingsoon.md @@ -0,0 +1 @@ +# Coming Soon \ No newline at end of file diff --git a/postinit.js b/postinit.js index 1ad0805..640e3be 100644 --- a/postinit.js +++ b/postinit.js @@ -843,13 +843,17 @@ globalThis.modapi_postinit = "(" + (() => { return x; } - const originalBootstrap = ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.init.Bootstrap", "register")]; - ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.init.Bootstrap", "register")] = function (...args) { - var x = originalBootstrap.apply(this, args); + ModAPI.util.bootstrap = function () { ModAPI.items = new Proxy(ModAPI.hooks._classMap[ModAPI.util.getCompiledName("net.minecraft.init.Items")].staticVariables, StaticProps_ProxyConf); ModAPI.blocks = new Proxy(ModAPI.hooks._classMap[ModAPI.util.getCompiledName("net.minecraft.init.Blocks")].staticVariables, StaticProps_ProxyConf); ModAPI.materials = new Proxy(ModAPI.hooks._classMap[ModAPI.util.getCompiledName("net.minecraft.block.material.Material")].staticVariables, StaticProps_ProxyConf); ModAPI.enchantments = new Proxy(ModAPI.hooks._classMap[ModAPI.util.getCompiledName("net.minecraft.enchantment.Enchantment")].staticVariables, StaticProps_ProxyConf); + } + + const originalBootstrap = ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.init.Bootstrap", "register")]; + ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.init.Bootstrap", "register")] = function (...args) { + var x = originalBootstrap.apply(this, args); + ModAPI.util.bootstrap(); console.log("[ModAPI] Hooked into bootstrap. .blocks, .items, .materials and .enchantments are now accessible."); return x; } diff --git a/roadmap.txt b/roadmap.txt deleted file mode 100644 index 3685ae1..0000000 --- a/roadmap.txt +++ /dev/null @@ -1,5 +0,0 @@ -*/*/ ZXMushroom63's rather large to do list */*/ - -Add makeItemStack to LCI [Todo] -Fix blocklook.js [In progress] -Fix setblocktest.js [In progress] \ No newline at end of file