mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-22 21:51:17 -09:00
1.12 compat XD
This commit is contained in:
parent
ec9c852bcd
commit
e04b084d28
@ -14,7 +14,7 @@ var modapi_preinit = `globalThis.ModAPI ||= {};
|
||||
`;
|
||||
var freezeCallstack = `if(ModAPI.hooks.freezeCallstack){return false};`;
|
||||
const EFIConfig = {
|
||||
ModAPIVersion: "v2.7.4", //also change in package.json
|
||||
ModAPIVersion: "v2.7.5", //also change in package.json
|
||||
doEaglerforge: true,
|
||||
verbose: false,
|
||||
doServerExtras: false,
|
||||
@ -375,9 +375,11 @@ var main;(function(){`
|
||||
|
||||
_status("Injecting scripts...");
|
||||
await wait(50);
|
||||
// 1.12 check is using nleit_MainClass, because peyton felt like renaming stuff. annoying, but useful too ig
|
||||
patchedFile = patchedFile.replace(
|
||||
` id="game_frame">`,
|
||||
` id="game_frame">
|
||||
\<script id="1_12_corelib_flag"\>ModAPI.is_1_12 = ${patchedFile.includes("nleit_MainClass_main")}\<\/script\>
|
||||
\<script id="modapi_patchesreg_events"\>${assets.PatchesRegistry.getEventInjectorCode()};\<\/script\>
|
||||
\<script id="modapi_postinit"\>${assets.modapi_postinit.replace("__modapi_version_code__", EFIConfig.ModAPIVersion)}\<\/script\>
|
||||
\<script id="modapi_modloader"\>${assets.modapi_modloader}\<\/script\>
|
||||
@ -388,6 +390,8 @@ var main;(function(){`
|
||||
);
|
||||
backgroundLog("[HTML] Injecting script files");
|
||||
patchedFile = patchedFile.replace(`<title>EaglercraftX`, `<title>EFI ${EFIConfig.ModAPIVersion} on`);
|
||||
patchedFile = patchedFile.replace(`<title>Eaglercraft`, `<title>EFI ${EFIConfig.ModAPIVersion} on`);
|
||||
|
||||
backgroundLog("[HTML] Injecting title");
|
||||
patchedFile = patchedFile.replaceAll(/main\(\);\s*?}/gm, (match) => {
|
||||
return match.replace("main();", "main();ModAPI.hooks._postInit();");
|
||||
|
@ -129,6 +129,16 @@ const modapi_postinit = "(" + (() => {
|
||||
}) : args))
|
||||
}
|
||||
}
|
||||
function easyAlias(obj, realProperty, alias) {
|
||||
Object.defineProperty(obj, alias, {
|
||||
get: function () {
|
||||
return obj[realProperty];
|
||||
},
|
||||
set: function (x) {
|
||||
obj[realProperty] = x;
|
||||
}
|
||||
});
|
||||
}
|
||||
ModAPI.meta.title = function (title) {
|
||||
if (!document.currentScript || document.currentScript.getAttribute("data-isMod") !== "true") {
|
||||
return console.log("[ModAPIMeta] Cannot set meta for non-mod script.");
|
||||
@ -203,6 +213,9 @@ const modapi_postinit = "(" + (() => {
|
||||
}
|
||||
ModAPI.util ||= {};
|
||||
ModAPI.util.getMethodFromPackage = function (classId, methodName) {
|
||||
if (ModAPI.is_1_12) {
|
||||
classId = classId.replace(".eaglercraft.v1_8", ".eaglercraft"); //why peyton why must you do this. you couldve changed it to v1_12 too, that would've worked
|
||||
}
|
||||
var name = "";
|
||||
var classStuff = classId.split(".");
|
||||
classStuff.forEach((component, i) => {
|
||||
@ -216,6 +229,9 @@ const modapi_postinit = "(" + (() => {
|
||||
return name;
|
||||
}
|
||||
ModAPI.util.getCompiledNameFromPackage = ModAPI.util.getCompiledName = function (classId) {
|
||||
if (ModAPI.is_1_12) {
|
||||
classId = classId.replace(".eaglercraft.v1_8", ".eaglercraft"); //why peyton why must you do this. you couldve changed it to v1_12 too, that would've worked
|
||||
}
|
||||
var name = "";
|
||||
var classStuff = classId.split(".");
|
||||
classStuff.forEach((component, i) => {
|
||||
@ -908,8 +924,16 @@ const modapi_postinit = "(" + (() => {
|
||||
globalThis.Minecraft = ModAPI.mcinstance = ModAPI.javaClient = args[0];
|
||||
ModAPI.settings = new Proxy(ModAPI.mcinstance.$gameSettings, TeaVM_to_Recursive_BaseData_ProxyConf);
|
||||
|
||||
|
||||
if (ModAPI.is_1_12) {
|
||||
easyAlias(ModAPI.javaClient, "$player", "$thePlayer");
|
||||
easyAlias(ModAPI.javaClient, "$world", "$theWorld");
|
||||
}
|
||||
|
||||
startModLoader();
|
||||
|
||||
ModAPI.hooks.methods[initMethodName] = originalInit; //unhook
|
||||
|
||||
return x;
|
||||
};
|
||||
|
||||
@ -1126,6 +1150,7 @@ const modapi_postinit = "(" + (() => {
|
||||
ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.lax1dude.eaglercraft.v1_8.internal.teavm.ClientMain", "_main")] = function (...args) {
|
||||
if ((!inited) && (!getEaglerConfigFlag("noInitialModGui"))) {
|
||||
inited = true;
|
||||
ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.lax1dude.eaglercraft.v1_8.internal.teavm.ClientMain", "_main")] = originalMainMethod; //unhook
|
||||
return modapi_displayModGui(globalThis.main);
|
||||
} else {
|
||||
return originalMainMethod.apply(this, args);
|
||||
|
@ -1,6 +1,6 @@
|
||||
(function grapplehook() {
|
||||
PluginAPI.require("player"); //Require the player
|
||||
var GrappleHookPlugin = {
|
||||
globalThis.GrappleHookPlugin = {
|
||||
oldXYZ: [0, 0, 0], //The previous hook position.
|
||||
prev: "NONE", //The previous state
|
||||
scaleH: 0.25, //Used for X and Z velocity
|
||||
@ -31,7 +31,7 @@
|
||||
if (
|
||||
player.fishEntity !== undefined && //If the fish hook exists
|
||||
GrappleHookPlugin.prev === "AIR" && //And the hook was previously in the air
|
||||
player.fishEntity.inGround //And the hook is in the ground
|
||||
(player.fishEntity.inGround || player.fishEntity.onGround) //And the hook is in the ground
|
||||
) {
|
||||
GrappleHookPlugin.oldXYZ = [ //Set old grapple hook position
|
||||
player.fishEntity.posX,
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "eaglerforgeinjector",
|
||||
"version": "2.7.4",
|
||||
"version": "2.7.5",
|
||||
"description": "Advanced modding API injector for unminified, unobfuscated, unsigned eaglercraft builds.",
|
||||
"main": "node.js",
|
||||
"directories": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user