diff --git a/core/core.js b/core/core.js index dd95f40..6529acf 100644 --- a/core/core.js +++ b/core/core.js @@ -14,7 +14,7 @@ var modapi_preinit = `globalThis.ModAPI ||= {}; `; var freezeCallstack = `if(ModAPI.hooks.freezeCallstack){return false};`; const EFIConfig = { - ModAPIVersion: "v2.7.8", //also change in package.json + ModAPIVersion: "v2.7.9", //also change in package.json doEaglerforge: true, verbose: false, doServerExtras: false, @@ -128,6 +128,7 @@ async function processClasses(string, parser) { assets.modapi_modloader = modapi_modloader; assets.modapi_guikit = modapi_guikit; } + _status("Running EaglerForgeInjector " + EFIConfig.ModAPIVersion); if (string.includes("__eaglerforgeinjector_installation_flag__")) { backgroundLog("Detected input containing EFI installation flag.", true); return alert("this file already has EaglerForge injected in it, you nonce.\nif you're trying to update, you need a vanilla file.") diff --git a/core/postinit.js b/core/postinit.js index 04a9ddc..bee8371 100644 --- a/core/postinit.js +++ b/core/postinit.js @@ -246,7 +246,6 @@ const modapi_postinit = "(" + (() => { } ModAPI.util.asClass = ModAPI.hooks._teavm.$rt_cls; - ModAPI.util.wrap = function (outputValue, target, corrective, disableFunctions) { target ||= {}; corrective ||= false; @@ -259,6 +258,16 @@ const modapi_postinit = "(" + (() => { } return new Proxy(outputValue.data, ModAPI.util.TeaVMArray_To_Recursive_BaseData_ProxyConf); } + if (ModAPI.is_1_12 && outputValue && typeof outputValue === "object" && outputValue.constructor === NonNullList) { //1.12 NonNullList support + const targetProperty = Object.values(outputValue)?.find(x => x && typeof x === "object" && x.constructor === ArrayAsList); + if (targetProperty) { + const arrayProp = Object.values(targetProperty).find(x => x && typeof x === "object" && Array.isArray(x.data) && typeof x.type === "function"); + if (corrective) { + return new Proxy(arrayProp.data, CorrectiveArray); + } + return new Proxy(arrayProp.data, ModAPI.util.TeaVMArray_To_Recursive_BaseData_ProxyConf); + } + } if (outputValue && typeof outputValue === "object" && !Array.isArray(outputValue)) { if (corrective) { return new Proxy(outputValue, CorrectiveRecursive); @@ -643,6 +652,7 @@ const modapi_postinit = "(" + (() => { get(target, prop, receiver) { var outProp = prop; var outputValue = Reflect.get(target, outProp, receiver); + outputValue ||= Reflect.get(target, outProp.toUpperCase(), receiver); //1.12 made a lot of variables uppercase (idk why) if (outputValue && typeof outputValue === "object" && Array.isArray(outputValue.data) && typeof outputValue.type === "function") { return new Proxy(outputValue.data, TeaVMArray_To_Recursive_BaseData_ProxyConf); } @@ -799,6 +809,9 @@ const modapi_postinit = "(" + (() => { //Function used for running @Async / @Async-dependent TeaVM methods. ModAPI.promisify = function promisify(fn) { + if (typeof fn !== "function") { + console.error("[ModAPI.promisify] Input was not a function: ", fn); + } return function promisifiedJavaMethod(...inArguments) { return new Promise((res, rej) => { Promise.resolve().then( //queue microtask @@ -1173,6 +1186,12 @@ const modapi_postinit = "(" + (() => { ModAPI.util.getBlockById = easyStaticMethod("net.minecraft.block.Block", "getBlockById", false); ModAPI.util.getBlockFromItem = easyStaticMethod("net.minecraft.block.Block", "getBlockFromItem", true); ModAPI.util.getIdFromBlock = easyStaticMethod("net.minecraft.block.Block", "getIdFromBlock", true); + + // 1.12 utility junk + if (ModAPI.is_1_12) { + var NonNullList = ModAPI.reflect.getClassById("net.minecraft.util.NonNullList").class; + var ArrayAsList = ModAPI.reflect.getClassById("java.util.Arrays$ArrayAsList").class; + } function qhash(txt, arr, interval) { // var interval = 4095; //used to be 4095 - arr.length, but that increases incompatibility based on load order and other circumstances diff --git a/examplemods/veinminer.js b/examplemods/veinminer.js index 408f953..5512e91 100644 --- a/examplemods/veinminer.js +++ b/examplemods/veinminer.js @@ -14,7 +14,7 @@ } catch (error) { //swallow } - ModAPI.meta.config(()=>{ + ModAPI.meta.config(() => { var conf = document.createElement("div"); conf.innerHTML = `