From 574b47897666916eb08ba6715586ce2784a82181 Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Fri, 23 Aug 2024 19:35:48 +0800 Subject: [PATCH] Add support for arrays --- examplemods/grapplehook.js | 2 +- injector.html | 22 ++++++++++++++++++---- postinit.js | 22 ++++++++++++++++++---- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/examplemods/grapplehook.js b/examplemods/grapplehook.js index e3ec430..cee1577 100644 --- a/examplemods/grapplehook.js +++ b/examplemods/grapplehook.js @@ -29,7 +29,7 @@ PluginAPI.addEventListener("update", () => { //Every client tick if ( PluginAPI.player.fishEntity !== undefined && //If the fish hook exists GrappleHookPlugin.prev === "AIR" && //And the hook was previously in the air - PluginAPI.player.fishEntity.onGround //And the hook is in the ground + PluginAPI.player.fishEntity.inGround2 //And the hook is in the ground ) { GrappleHookPlugin.oldXYZ = [ //Set old grapple hook position PluginAPI.player.fishEntity.posX, diff --git a/injector.html b/injector.html index e4a2c8d..8d5aeaa 100644 --- a/injector.html +++ b/injector.html @@ -382,10 +382,8 @@

var outProp = "$" + prop; var outputValue = Reflect.get(target, outProp, receiver); - if (outputValue && typeof outputValue === "function") { - return function (...args) { - return outputValue.apply(target, args); - } + if (outputValue && typeof outputValue === "object" && Array.isArray(outputValue.data) && typeof outputValue.type === "function") { + return outputValue.data; } if (outputValue && typeof outputValue === "function") { return function (...args) { @@ -400,6 +398,19 @@

return true; }, }; + const TeaVMArray_To_Recursive_BaseData_ProxyConf = { + get(target, prop, receiver) { + var outputValue = Reflect.get(target, prop, receiver); + if (outputValue && typeof outputValue === "object" && !Array.isArray(outputValue)) { + return new Proxy(outputValue, TeaVM_to_Recursive_BaseData_ProxyConf); + } + return outputValue; + }, + set(object, prop, value) { + object[prop]=value; + return true; + } + } const TeaVM_to_Recursive_BaseData_ProxyConf = { get(target, prop, receiver) { if (prop === "reload") { @@ -413,6 +424,9 @@

var outProp = "$" + prop; var outputValue = Reflect.get(target, outProp, receiver); + if (outputValue && typeof outputValue === "object" && Array.isArray(outputValue.data) && typeof outputValue.type === "function") { + return new Proxy(outputValue.data, TeaVMArray_To_Recursive_BaseData_ProxyConf); + } if (outputValue && typeof outputValue === "object" && !Array.isArray(outputValue)) { return new Proxy(outputValue, TeaVM_to_Recursive_BaseData_ProxyConf); } diff --git a/postinit.js b/postinit.js index d766fba..931233f 100644 --- a/postinit.js +++ b/postinit.js @@ -76,10 +76,8 @@ var outProp = "$" + prop; var outputValue = Reflect.get(target, outProp, receiver); - if (outputValue && typeof outputValue === "function") { - return function (...args) { - return outputValue.apply(target, args); - } + if (outputValue && typeof outputValue === "object" && Array.isArray(outputValue.data) && typeof outputValue.type === "function") { + return outputValue.data; } if (outputValue && typeof outputValue === "function") { return function (...args) { @@ -94,6 +92,19 @@ return true; }, }; + const TeaVMArray_To_Recursive_BaseData_ProxyConf = { + get(target, prop, receiver) { + var outputValue = Reflect.get(target, prop, receiver); + if (outputValue && typeof outputValue === "object" && !Array.isArray(outputValue)) { + return new Proxy(outputValue, TeaVM_to_Recursive_BaseData_ProxyConf); + } + return outputValue; + }, + set(object, prop, value) { + object[prop]=value; + return true; + } + } const TeaVM_to_Recursive_BaseData_ProxyConf = { get(target, prop, receiver) { if (prop === "reload") { @@ -107,6 +118,9 @@ var outProp = "$" + prop; var outputValue = Reflect.get(target, outProp, receiver); + if (outputValue && typeof outputValue === "object" && Array.isArray(outputValue.data) && typeof outputValue.type === "function") { + return new Proxy(outputValue.data, TeaVMArray_To_Recursive_BaseData_ProxyConf); + } if (outputValue && typeof outputValue === "object" && !Array.isArray(outputValue)) { return new Proxy(outputValue, TeaVM_to_Recursive_BaseData_ProxyConf); }