mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-24 14:41:18 -09:00
u37 fixes
This commit is contained in:
parent
814104e758
commit
d872980fc4
@ -42,3 +42,5 @@ Methods:
|
|||||||
- The class parameter can be retrieved via reflect: `ModAPI.reflect.getClassById("net.minecraft.util.BlockPos").class`
|
- The class parameter can be retrieved via reflect: `ModAPI.reflect.getClassById("net.minecraft.util.BlockPos").class`
|
||||||
- `ModAPI.util.wrap(obj: Object) : object`
|
- `ModAPI.util.wrap(obj: Object) : object`
|
||||||
- Returns a wrapper around native java objects, removing prefixes and fixing method outputs.
|
- 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.
|
@ -2,7 +2,7 @@
|
|||||||
When TeaVM compiles code, it sometimes does strange things.
|
When TeaVM compiles code, it sometimes does strange things.
|
||||||
|
|
||||||
#### Property Suffixes
|
#### 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
|
#### 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.
|
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.
|
||||||
|
@ -29,7 +29,7 @@ PluginAPI.addEventListener("update", () => { //Every client tick
|
|||||||
if (
|
if (
|
||||||
PluginAPI.player.fishEntity !== undefined && //If the fish hook exists
|
PluginAPI.player.fishEntity !== undefined && //If the fish hook exists
|
||||||
GrappleHookPlugin.prev === "AIR" && //And the hook was previously in the air
|
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
|
GrappleHookPlugin.oldXYZ = [ //Set old grapple hook position
|
||||||
PluginAPI.player.fishEntity.posX,
|
PluginAPI.player.fishEntity.posX,
|
||||||
|
@ -59,9 +59,10 @@
|
|||||||
if (!globalThis.LCI_LMBEVENTS[cid]) {
|
if (!globalThis.LCI_LMBEVENTS[cid]) {
|
||||||
return oldDig.apply(this, [$this, packet]);
|
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 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") {
|
if (stat === "START_DESTROY_BLOCK") {
|
||||||
sendPacket($this, packetblockchange($this.$serverController.$worldServerForDimension($this.$playerEntity.$dimension), packet[positionTag]));
|
sendPacket($this, packetblockchange($this.$serverController.$worldServerForDimension($this.$playerEntity.$dimension), packet[positionTag]));
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,9 @@
|
|||||||
>Choose .html file...</label
|
>Choose .html file...</label
|
||||||
>
|
>
|
||||||
<br />
|
<br />
|
||||||
<span><code id="status">Awaiting input...</code></span>
|
<span><label>Minify: </label><input type="checkbox" oninput="globalThis.doShronk = this.checked">
|
||||||
|
<label>EaglerForge: </label><input checked type="checkbox" oninput="globalThis.doEaglerforge = this.checked">
|
||||||
|
<code id="status">Awaiting input...</code></span>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
<button class="btn btn-primary" id="giveme">Make modded client</button>
|
<button class="btn btn-primary" id="giveme">Make modded client</button>
|
||||||
<button class="btn btn-primary" id="givemeserver" disabled>
|
<button class="btn btn-primary" id="givemeserver" disabled>
|
||||||
@ -172,7 +174,7 @@
|
|||||||
`;
|
`;
|
||||||
var freezeCallstack = `if(ModAPI.hooks.freezeCallstack){return false};`;
|
var freezeCallstack = `if(ModAPI.hooks.freezeCallstack){return false};`;
|
||||||
</script>
|
</script>
|
||||||
<script src="injector.stepAsync.js"></script>
|
<script src="injector.minify.js"></script>
|
||||||
<script src="injector.js"></script>
|
<script src="injector.js"></script>
|
||||||
|
|
||||||
<!-- Code assets -->
|
<!-- Code assets -->
|
||||||
|
29
injector.js
29
injector.js
@ -1,3 +1,4 @@
|
|||||||
|
globalThis.doEaglerforge = true;
|
||||||
function wait(ms) {
|
function wait(ms) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
setTimeout(() => { resolve(); }, ms);
|
setTimeout(() => { resolve(); }, ms);
|
||||||
@ -231,10 +232,14 @@ var main;(function(){`
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
_status("Applying async override...");
|
if (globalThis.doShronk) {
|
||||||
|
_status("Shrinking file...");
|
||||||
await wait(50);
|
await wait(50);
|
||||||
|
|
||||||
//patchedFile = await asyncify(patchedFile);
|
patchedFile = await shronk(patchedFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
_status("Injecting scripts...");
|
_status("Injecting scripts...");
|
||||||
await wait(50);
|
await wait(50);
|
||||||
patchedFile = patchedFile.replace(
|
patchedFile = patchedFile.replace(
|
||||||
@ -268,8 +273,15 @@ document.querySelector("#giveme").addEventListener("click", () => {
|
|||||||
fileType = fileType[fileType.length - 1];
|
fileType = fileType[fileType.length - 1];
|
||||||
|
|
||||||
file.text().then(async (string) => {
|
file.text().then(async (string) => {
|
||||||
var patchedFile = await processClasses(string);
|
var patchedFile = string;
|
||||||
patchedFile.replace(`{"._|_libserverside_|_."}`)
|
|
||||||
|
if (globalThis.doEaglerforge) {
|
||||||
|
patchedFile = await processClasses(patchedFile);
|
||||||
|
} else if (globalThis.doShronk) {
|
||||||
|
patchedFile = await shronk(patchedFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
patchedFile.replace(`{"._|_libserverside_|_."}`, "");
|
||||||
var blob = new Blob([patchedFile], { type: file.type });
|
var blob = new Blob([patchedFile], { type: file.type });
|
||||||
saveAs(blob, "processed." + fileType);
|
saveAs(blob, "processed." + fileType);
|
||||||
});
|
});
|
||||||
@ -288,7 +300,14 @@ document.querySelector("#givemeserver").addEventListener("click", () => {
|
|||||||
fileType = fileType[fileType.length - 1];
|
fileType = fileType[fileType.length - 1];
|
||||||
|
|
||||||
file.text().then(async (string) => {
|
file.text().then(async (string) => {
|
||||||
var patchedFile = await processClasses(string);
|
var patchedFile = string;
|
||||||
|
|
||||||
|
if (globalThis.doEaglerforge) {
|
||||||
|
patchedFile = await processClasses(patchedFile);
|
||||||
|
} else if (globalThis.doShronk) {
|
||||||
|
patchedFile = await shronk(patchedFile);
|
||||||
|
}
|
||||||
|
|
||||||
patchedFile.replace(`{"._|_libserverside_|_."}`, `(${EFServer.toString()})()`);
|
patchedFile.replace(`{"._|_libserverside_|_."}`, `(${EFServer.toString()})()`);
|
||||||
var blob = new Blob([patchedFile], { type: file.type });
|
var blob = new Blob([patchedFile], { type: file.type });
|
||||||
saveAs(blob, "efserver." + fileType);
|
saveAs(blob, "efserver." + fileType);
|
||||||
|
@ -21,7 +21,7 @@ const ASYNC_PLUGIN_1 = function ({ types: t }) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
async function asyncify(input) {
|
async function shronk(input) {
|
||||||
let isHtml = true;
|
let isHtml = true;
|
||||||
let inputHtml = input;
|
let inputHtml = input;
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ async function asyncify(input) {
|
|||||||
|
|
||||||
|
|
||||||
const output = Babel.transform(code, {
|
const output = Babel.transform(code, {
|
||||||
plugins: [ASYNC_PLUGIN_1]
|
plugins: []
|
||||||
});
|
});
|
||||||
scriptTag.textContent = output.code;
|
scriptTag.textContent = output.code;
|
||||||
}
|
}
|
19
postinit.js
19
postinit.js
@ -571,6 +571,19 @@ globalThis.modapi_postinit = "(" + (() => {
|
|||||||
return ModAPI.hooks._teavm.$rt_suspending() || ModAPI.hooks._teavm.$rt_resuming();
|
return ModAPI.hooks._teavm.$rt_suspending() || ModAPI.hooks._teavm.$rt_resuming();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ModAPI.util.getNearestProperty = function getNearestProperty(object, prop) {
|
||||||
|
if (!object) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var possibleKeys = Object.keys(object).filter(x => { return x.startsWith(prop) });
|
||||||
|
possibleKeys = possibleKeys.filter(x => {
|
||||||
|
return Number.isFinite(parseInt(x.substring(prop.length))) || (x.substring(prop.length).length === 0);
|
||||||
|
})
|
||||||
|
return possibleKeys.sort((a, b) => {
|
||||||
|
return a.length - b.length;
|
||||||
|
})[0] || null;
|
||||||
|
}
|
||||||
|
|
||||||
ModAPI.clickMouse = function () {
|
ModAPI.clickMouse = function () {
|
||||||
ModAPI.hooks.methods["nmc_Minecraft_clickMouse"](ModAPI.javaClient);
|
ModAPI.hooks.methods["nmc_Minecraft_clickMouse"](ModAPI.javaClient);
|
||||||
}
|
}
|
||||||
@ -750,7 +763,8 @@ globalThis.modapi_postinit = "(" + (() => {
|
|||||||
|
|
||||||
// Find the right constructor. (int id, int x, int y, int width, int height, String buttonText);
|
// Find the right constructor. (int id, int x, int y, int width, int height, String buttonText);
|
||||||
var btnConstructor = ModAPI.hooks._classMap['nmcg_GuiButton'].constructors.filter(c => { return c.length === 6 })[0];
|
var btnConstructor = ModAPI.hooks._classMap['nmcg_GuiButton'].constructors.filter(c => { return c.length === 6 })[0];
|
||||||
var btn = btnConstructor(9635329, 0, args[0].$height8 - 21, 100, 20, ModAPI.util.str(msg));
|
var heightProp = ModAPI.util.getNearestProperty(args[0], "$height");
|
||||||
|
var btn = btnConstructor(9635329, 0, args[0][heightProp] - 21, 100, 20, ModAPI.util.str(msg));
|
||||||
args[0].$buttonList.$add(btn);
|
args[0].$buttonList.$add(btn);
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
@ -758,7 +772,8 @@ globalThis.modapi_postinit = "(" + (() => {
|
|||||||
|
|
||||||
const originalOptionsAction = ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.gui.GuiOptions", "actionPerformed")];
|
const originalOptionsAction = ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.gui.GuiOptions", "actionPerformed")];
|
||||||
ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.gui.GuiOptions", "actionPerformed")] = function (...args) {
|
ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.gui.GuiOptions", "actionPerformed")] = function (...args) {
|
||||||
if (args[1] && args[1].$id12 === 9635329) {
|
var idProp = ModAPI.util.getNearestProperty(args[1], "$id");
|
||||||
|
if (args[1] && args[1][idProp] === 9635329) {
|
||||||
if (typeof window.modapi_displayModGui === "function") {
|
if (typeof window.modapi_displayModGui === "function") {
|
||||||
window.modapi_displayModGui();
|
window.modapi_displayModGui();
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user