Skip to content

Commit

Permalink
Add support for arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
ZXMushroom63 committed Aug 23, 2024
1 parent 4aebb8b commit 574b478
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examplemods/grapplehook.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
22 changes: 18 additions & 4 deletions injector.html
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,8 @@ <h4>
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) {
Expand All @@ -400,6 +398,19 @@ <h4>
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") {
Expand All @@ -413,6 +424,9 @@ <h4>
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);
}
Expand Down
22 changes: 18 additions & 4 deletions postinit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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") {
Expand All @@ -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);
}
Expand Down

0 comments on commit 574b478

Please sign in to comment.