small change to static key processing

This commit is contained in:
ZXMushroom63 2025-06-28 13:43:29 +08:00
parent 645970a98b
commit 6b6b7db2b1
2 changed files with 6 additions and 2 deletions

View File

@ -351,12 +351,16 @@ const modapi_postinit = "(" + (() => {
return ModAPI.hooks._teavm.$rt_createDoubleArray(size); return ModAPI.hooks._teavm.$rt_createDoubleArray(size);
} }
function staticKeyMapper(k) {
return k.split(/(?=[A-Z])/).map(x=>x.toUpperCase()).join("_");
}
//Proxy to make sure static variables are initialized before access, as well as fixing some issues in 1.12 //Proxy to make sure static variables are initialized before access, as well as fixing some issues in 1.12
function makeClinitProxy(staticVariables, clinit) { function makeClinitProxy(staticVariables, clinit) {
return new Proxy(staticVariables, { return new Proxy(staticVariables, {
get: function (a, b, c) { get: function (a, b, c) {
clinit(); clinit();
return Reflect.get(a, b, c) || Reflect.get(a, b.toUpperCase(), c); return Reflect.get(a, b, c) || Reflect.get(a, staticKeyMapper(b), c);
} }
}); });
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "eaglerforgeinjector", "name": "eaglerforgeinjector",
"version": "2.7.94", "version": "2.7.94b",
"description": "Advanced modding API injector for unminified, unobfuscated, unsigned eaglercraft builds.", "description": "Advanced modding API injector for unminified, unobfuscated, unsigned eaglercraft builds.",
"main": "node.js", "main": "node.js",
"directories": { "directories": {