mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-23 06:01:38 -09:00
Add displayToChat, js string to jcl string
This commit is contained in:
parent
d33afdeff6
commit
4aebb8bab7
@ -9,7 +9,7 @@ var GrappleHookPlugin = {
|
||||
};
|
||||
PluginAPI.addEventListener("update", () => { //Every client tick
|
||||
if (!PluginAPI.player.fishEntity) { //If the fish hook does not exist.
|
||||
if (GrappleHookPlugin.prev === "GROUND" && (!GrappleHookPlugin.crouchToCancel || !PluginAPI.player.isSneaking.apply(PluginAPI.javaClient.$thePlayer, []))) { //If the old state was ground
|
||||
if (GrappleHookPlugin.prev === "GROUND" && (!GrappleHookPlugin.crouchToCancel || !PluginAPI.player.isSneaking())) { //If the old state was ground
|
||||
GrappleHookPlugin.prev = "NONE"; //Update the state
|
||||
var mx = GrappleHookPlugin.oldXYZ[0] - PluginAPI.player.posX; //Get delta X
|
||||
var my = GrappleHookPlugin.oldXYZ[1] - PluginAPI.player.posY; //Get delta Y
|
||||
|
@ -6,7 +6,7 @@
|
||||
<title>EaglerForge Injector</title>
|
||||
<style>
|
||||
* {
|
||||
font-family: sans-serif;
|
||||
font-family: monospace;
|
||||
}
|
||||
button {
|
||||
border: 2px solid black;
|
||||
@ -249,9 +249,9 @@ var main;(function(){`
|
||||
);
|
||||
|
||||
const extractConstructorRegex =
|
||||
/^\s*function (\S*?)__init_\d+?\((?!\$)/gm;
|
||||
/^\s*function (\S*?)__init_\d*?\((?!\$)/gm;
|
||||
const extractConstructorFullNameRegex =
|
||||
/function (\S*?)__init_[0-9]+/gm;
|
||||
/function (\S*?)__init_[0-9]*/gm;
|
||||
patchedFile = patchedFile.replaceAll(
|
||||
extractConstructorRegex,
|
||||
(match) => {
|
||||
@ -285,7 +285,7 @@ var main;(function(){`
|
||||
}
|
||||
ModAPI.hooks._rippedMethodTypeMap[\`${fullName}\`] = \`${
|
||||
match.includes("function " + fullName + "($this")
|
||||
? "instance"
|
||||
? "instance" //Todo: fix static/instance detection
|
||||
: "static"
|
||||
}\`;
|
||||
ModAPI.hooks.methods[\`${fullName}\`]=` +
|
||||
@ -381,8 +381,18 @@ var main;(function(){`
|
||||
}
|
||||
|
||||
var outProp = "$" + prop;
|
||||
console.log(outProp);
|
||||
return Reflect.get(target, outProp, receiver);
|
||||
var outputValue = Reflect.get(target, outProp, receiver);
|
||||
if (outputValue && typeof outputValue === "function") {
|
||||
return function (...args) {
|
||||
return outputValue.apply(target, args);
|
||||
}
|
||||
}
|
||||
if (outputValue && typeof outputValue === "function") {
|
||||
return function (...args) {
|
||||
return outputValue.apply(target, args);
|
||||
}
|
||||
}
|
||||
return outputValue;
|
||||
},
|
||||
set(object, prop, value) {
|
||||
var outProp = "$" + prop;
|
||||
@ -403,9 +413,14 @@ var main;(function(){`
|
||||
|
||||
var outProp = "$" + prop;
|
||||
var outputValue = Reflect.get(target, outProp, receiver);
|
||||
if (outputValue && typeof outputValue === "object") {
|
||||
if (outputValue && typeof outputValue === "object" && !Array.isArray(outputValue)) {
|
||||
return new Proxy(outputValue, TeaVM_to_Recursive_BaseData_ProxyConf);
|
||||
}
|
||||
if (outputValue && typeof outputValue === "function") {
|
||||
return function (...args) {
|
||||
return outputValue.apply(target, args);
|
||||
}
|
||||
}
|
||||
return outputValue;
|
||||
},
|
||||
set(object, prop, value) {
|
||||
@ -519,6 +534,30 @@ var main;(function(){`
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
ModAPI.util.stringToUint16Array = function stringToUint16Array(str) {
|
||||
const buffer = new ArrayBuffer(str.length * 2); // 2 bytes for each char
|
||||
const uint16Array = new Uint16Array(buffer);
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
uint16Array[i] = str.charCodeAt(i);
|
||||
}
|
||||
return uint16Array;
|
||||
}
|
||||
|
||||
var stringDefaultConstructor = ModAPI.hooks._classMap["java.lang.String"].constructors.filter(x => {return x.length === 0})[0];
|
||||
ModAPI.util.string = ModAPI.util.str = function (string) {
|
||||
var jclString = stringDefaultConstructor();
|
||||
jclString.$characters.data = ModAPI.util.stringToUint16Array(string);
|
||||
return jclString;
|
||||
}
|
||||
|
||||
ModAPI.displayToChat = function (param) {
|
||||
var v = typeof param === "object" ? param.msg : (param + "");
|
||||
v ||= "";
|
||||
var jclString = ModAPI.util.string(v);
|
||||
ModAPI.hooks.methods["nmcg_GuiNewChat_printChatMessage"](ModAPI.javaClient.$ingameGUI.$persistantChatGUI, ModAPI.hooks._classMap["net.minecraft.util.ChatComponentText"].constructors[0](jclString));
|
||||
}
|
||||
|
||||
const updateMethodName = ModAPI.util.getMethodFromPackage("net.minecraft.client.entity.EntityPlayerSP", "onUpdate");
|
||||
const originalUpdate = ModAPI.hooks.methods[updateMethodName];
|
||||
ModAPI.hooks.methods[updateMethodName] = function (...args) {
|
||||
|
45
postinit.js
45
postinit.js
@ -75,8 +75,18 @@
|
||||
}
|
||||
|
||||
var outProp = "$" + prop;
|
||||
console.log(outProp);
|
||||
return Reflect.get(target, outProp, receiver);
|
||||
var outputValue = Reflect.get(target, outProp, receiver);
|
||||
if (outputValue && typeof outputValue === "function") {
|
||||
return function (...args) {
|
||||
return outputValue.apply(target, args);
|
||||
}
|
||||
}
|
||||
if (outputValue && typeof outputValue === "function") {
|
||||
return function (...args) {
|
||||
return outputValue.apply(target, args);
|
||||
}
|
||||
}
|
||||
return outputValue;
|
||||
},
|
||||
set(object, prop, value) {
|
||||
var outProp = "$" + prop;
|
||||
@ -97,9 +107,14 @@
|
||||
|
||||
var outProp = "$" + prop;
|
||||
var outputValue = Reflect.get(target, outProp, receiver);
|
||||
if (outputValue && typeof outputValue === "object") {
|
||||
if (outputValue && typeof outputValue === "object" && !Array.isArray(outputValue)) {
|
||||
return new Proxy(outputValue, TeaVM_to_Recursive_BaseData_ProxyConf);
|
||||
}
|
||||
if (outputValue && typeof outputValue === "function") {
|
||||
return function (...args) {
|
||||
return outputValue.apply(target, args);
|
||||
}
|
||||
}
|
||||
return outputValue;
|
||||
},
|
||||
set(object, prop, value) {
|
||||
@ -213,6 +228,30 @@
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
ModAPI.util.stringToUint16Array = function stringToUint16Array(str) {
|
||||
const buffer = new ArrayBuffer(str.length * 2); // 2 bytes for each char
|
||||
const uint16Array = new Uint16Array(buffer);
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
uint16Array[i] = str.charCodeAt(i);
|
||||
}
|
||||
return uint16Array;
|
||||
}
|
||||
|
||||
var stringDefaultConstructor = ModAPI.hooks._classMap["java.lang.String"].constructors.filter(x => {return x.length === 0})[0];
|
||||
ModAPI.util.string = ModAPI.util.str = function (string) {
|
||||
var jclString = stringDefaultConstructor();
|
||||
jclString.$characters.data = ModAPI.util.stringToUint16Array(string);
|
||||
return jclString;
|
||||
}
|
||||
|
||||
ModAPI.displayToChat = function (param) {
|
||||
var v = typeof param === "object" ? param.msg : (param + "");
|
||||
v ||= "";
|
||||
var jclString = ModAPI.util.string(v);
|
||||
ModAPI.hooks.methods["nmcg_GuiNewChat_printChatMessage"](ModAPI.javaClient.$ingameGUI.$persistantChatGUI, ModAPI.hooks._classMap["net.minecraft.util.ChatComponentText"].constructors[0](jclString));
|
||||
}
|
||||
|
||||
const updateMethodName = ModAPI.util.getMethodFromPackage("net.minecraft.client.entity.EntityPlayerSP", "onUpdate");
|
||||
const originalUpdate = ModAPI.hooks.methods[updateMethodName];
|
||||
ModAPI.hooks.methods[updateMethodName] = function (...args) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user