diff --git a/docs/apidoc/utils.md b/docs/apidoc/utils.md
index 734e950..8446a71 100644
--- a/docs/apidoc/utils.md
+++ b/docs/apidoc/utils.md
@@ -41,4 +41,6 @@ Methods:
- 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`
- `ModAPI.util.wrap(obj: Object) : object`
- - Returns a wrapper around native java objects, removing prefixes and fixing method outputs.
\ No newline at end of file
+ - Returns a wrapper around native java objects, removing prefixes and fixing method outputs.
+- `ModAPI.util.getNearestProperty(object: Object, property: string) : string`
+ - Finds the nearest property name to the one you specify (suffix based). This is used to mitigate teavm adding random suffixes to properties.
\ No newline at end of file
diff --git a/docs/quirks.md b/docs/quirks.md
index d2cff39..92e3643 100644
--- a/docs/quirks.md
+++ b/docs/quirks.md
@@ -2,7 +2,7 @@
When TeaVM compiles code, it sometimes does strange things.
#### Property Suffixes
-TeaVM will add suffixes to some variables, seemingly randomly. An example is the property `inGround` of any entity. When accessing this on the `ModAPI.player.fishEntity` object, TeaVM has renamed it to `inGround2`.
+TeaVM will add suffixes to some variables, seemingly randomly. An example is the property `inGround` of any entity. When accessing this on the `ModAPI.player.fishEntity` object, TeaVM has renamed it to `inGround2`. Can be mitigated with `ModAPI.util.getNearestProperty`.
#### Collapsing Methods
When I was trying to hook into the server-side processing of chat messages, I found that chat packets were handled by the method `processChatMessage` in `NetHandlerPlayServer`. However, in the compiled JavaScript, this method no longer exists. This is because it is only used once, in the `processPacket` method of `C01PacketChatMessage`. TeaVM automatically saw this, and collapsed one method into the other.
diff --git a/examplemods/grapplehook.js b/examplemods/grapplehook.js
index cee1577..2595f04 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.inGround2 //And the hook is in the ground
+ PluginAPI.player.fishEntity[PluginAPI.util.getNearestProperty(ModAPI.player.fishEntity, "inGround")] //And the hook is in the ground (the inGround property is botched with random suffixes sometimes)
) {
GrappleHookPlugin.oldXYZ = [ //Set old grapple hook position
PluginAPI.player.fishEntity.posX,
diff --git a/examplemods/lib.customitems.js b/examplemods/lib.customitems.js
index 8afbb3a..8e12501 100644
--- a/examplemods/lib.customitems.js
+++ b/examplemods/lib.customitems.js
@@ -59,9 +59,10 @@
if (!globalThis.LCI_LMBEVENTS[cid]) {
return oldDig.apply(this, [$this, packet]);
}
- var statusTag = Object.keys(packet.$status).find(x => { return x.startsWith("$name") });
+ var $status = ModAPI.util.getNearestProperty(packet, "$status");
+ var statusTag = Object.keys(packet[$status]).find(x => { return x.startsWith("$name") });
var positionTag = Object.keys(packet).filter(x => { return x.startsWith("$position") })[0];
- var stat = ModAPI.util.unstr(packet.$status[statusTag]);
+ var stat = ModAPI.util.unstr(packet[$status][statusTag]);
if (stat === "START_DESTROY_BLOCK") {
sendPacket($this, packetblockchange($this.$serverController.$worldServerForDimension($this.$playerEntity.$dimension), packet[positionTag]));
}
diff --git a/index.html b/index.html
index 7affca3..dd3c385 100644
--- a/index.html
+++ b/index.html
@@ -90,7 +90,9 @@
>Choose .html file...
- Awaiting input...
+
+
+ Awaiting input...