Fix bad link, add function to manually regenerate bootstrap

This commit is contained in:
ZXMushroom63 2024-11-01 15:33:14 +08:00
parent 4779e00f1c
commit 34607605a2
4 changed files with 10 additions and 8 deletions

View File

@ -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`

View File

@ -0,0 +1 @@
# Coming Soon

View File

@ -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;
}

View File

@ -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]