diff --git a/docs/apidoc/index.md b/docs/apidoc/index.md index 8f1d0dd..cdfaf9b 100644 --- a/docs/apidoc/index.md +++ b/docs/apidoc/index.md @@ -100,6 +100,8 @@ The ModAPI object has the following methods: - `promisify(asyncJavaMethod: Method | Constructor) : PromisifiedJavaRunner` - Allows running java methods that are @Async/@Async dependent. - More [PromisifyDocumentation](promisify.md) + - `addCredit(category: String, contributor: String, contents: String)` + - Lets you easily add credits to Eaglercraft's credits.txt ## Handling strings, numbers and booleans to and from java. diff --git a/injector.js b/injector.js index 4cb8de0..f705d87 100644 --- a/injector.js +++ b/injector.js @@ -1,4 +1,4 @@ -globalThis.ModAPIVersion = "v2.7.1"; +globalThis.ModAPIVersion = "v2.7.2"; globalThis.doEaglerforge = true; document.querySelector("title").innerText = `EaglerForge Injector ${ModAPIVersion}`; document.querySelector("h1").innerText = `EaglerForge Injector ${ModAPIVersion}`; diff --git a/postinit.js b/postinit.js index 074db62..0ae13ec 100644 --- a/postinit.js +++ b/postinit.js @@ -3,6 +3,7 @@ globalThis.modapi_postinit = "(" + (() => { //This script cannot contain backticks, escape characters, or backslashes in order to inject into the dedicated server code. var startedModLoader = false; var BACKSLASH = String.fromCharCode(92); + var LF = String.fromCharCode(10); var STRIP_COMMENTS = new RegExp(atob("KChcL1wvLiokKXwoXC9cKltcc1xTXSo/XCpcLykp"), "gm"); var ARGUMENT_NAMES = new RegExp(atob("KFteXHMsXSsp"), "g"); @@ -24,12 +25,57 @@ globalThis.modapi_postinit = "(" + (() => { ModAPI.meta._developerMap = {}; ModAPI.meta._iconMap = {}; ModAPI.meta._versionMap = {}; + const credits = {}; + ModAPI.addCredit = function (category, name, contents) { + if (!credits[category]) { + credits[category] = []; + } + credits[category].push(LF + LF + " " + name + ": " + LF + LF + contents); + } + function getCreditsString() { + return Object.entries(credits).map((entry) => { + return " "+entry[0] + LF + " " + (new Array(entry[0].length)).fill("~").join("") + entry[1].join("") + LF + LF + LF; + }).join(""); + } ModAPI.array = {}; ModAPI.version = "__modapi_version_code__"; ModAPI.flavour = "injector"; ModAPI.GNU = "terry pratchett"; - ModAPI.credits = ["ZXMushroom63", "radmanplays", "Murturtle", "OtterCodes101", "TheIdiotPlays", "OeildeLynx31", "Stpv22"]; + + ModAPI.addCredit("EaglerForge Devs", "ZXMushroom63", + " - Built the original PluginAPI for EaglerReborn" + LF + + " - Built EaglerForgeInjector as a procedural replacement for EaglerForge clients" + LF + + " - Made the mod loader and gui loader" + LF + + " - Added singleplayer support" + LF + + " - Made the AsyncSink corelib"); + + ModAPI.addCredit("EaglerForge Devs", "radmanplays", + " - Ported and maintained EaglerReborn's PluginAPI to modern version of eaglercrafts (u22+)" + LF + + " - Rebranded PluginAPI to ModAPI" + LF + + " - Added various new features to ModAPI" + LF + + " - Made the worldedit mod + a few other mods"); + + ModAPI.addCredit("EaglerForge Devs", "LeahOnBrainrot / OtterCodes101 / OtterDev", + " - Created EaglerReborn" + LF + + " - EaglerForge developer" + LF + + " - Helped update the client to newer versions" + LF + + " - Made signed clients work" + LF + + " - Maintainer nowadays" + LF + + " - Various bug fixes for EaglerForgeInjector"); + + ModAPI.addCredit("EaglerForge Devs", "Murturtle", + " - Added the render event to EaglerForgeInjector" + LF + + " - Added pi optimiser to the injector (now removed)"); + + ModAPI.addCredit("EaglerForge Devs", "TheIdiotPlays", + " - Made the mod manager GUI"); + + ModAPI.addCredit("EaglerForge Devs", "OeildeLynx31", + " - Work on the worldedit mod"); + + ModAPI.addCredit("EaglerForge Devs", "Stpv22", + " - Made the mod gui open before the client starts"); function limitSize(x, n) { if (x.length > n) { @@ -41,20 +87,20 @@ globalThis.modapi_postinit = "(" + (() => { function arraysAreSame(arr1, arr2) { if (!arr1 || !arr2) return false; - if(arr1 === arr2) + if (arr1 === arr2) return true; if (arr1.length !== arr2.length) return false; - for (var i = 0, l=arr1.length; i < l; i++) { + for (var i = 0, l = arr1.length; i < l; i++) { if (arr1[i] instanceof Array && arr2[i] instanceof Array) { if (!arr1[i].equals(arr2[i])) - return false; + return false; } else if (arr1[i] !== arr2[i]) { - return false; - } - } + return false; + } + } return true; } function getParamNames(func) { @@ -343,7 +389,7 @@ globalThis.modapi_postinit = "(" + (() => { "getConstructorByArgs": function (...argNames) { if (!argumentCache) { argumentCache = []; - this.internalConstructors.forEach(x=>{ + this.internalConstructors.forEach(x => { argumentCache.push(getParamNames(x).slice(1).map(y => y.substring(1))); }); } @@ -821,6 +867,22 @@ globalThis.modapi_postinit = "(" + (() => { return originalUpdate.apply(this, args); }; + const getCreditsName = ModAPI.util.getMethodFromPackage("net.lax1dude.eaglercraft.v1_8.EagRuntime", "getResourceString"); + const originalGetCredits = ModAPI.hooks.methods[getCreditsName]; + ModAPI.hooks.methods[getCreditsName] = function ($path) { + if (!$path) { + return originalGetCredits.apply(this, [$path]); + } + if (ModAPI.util.ustr($path).toLowerCase().endsWith("credits.txt")) { + var out = originalGetCredits.apply(this, [$path]); + out = ModAPI.util.ustr(out); + out = getCreditsString() + out; + out = ModAPI.util.str(out); + return out; + } + return originalGetCredits.apply(this, [$path]); + }; + const initMethodName = ModAPI.util.getMethodFromPackage("net.minecraft.client.Minecraft", "startGame"); const originalInit = ModAPI.hooks.methods[initMethodName]; ModAPI.hooks.methods[initMethodName] = function (...args) { @@ -1105,7 +1167,7 @@ globalThis.modapi_postinit = "(" + (() => { } ModAPI.keygen.entity = function (entity) { var hashMap = ModAPI.util.wrap(ModAPI.reflect.getClassById("net.minecraft.entity.EntityList").staticVariables.idToClassMapping).getCorrective(); - var values = hashMap.keys.getRef().data.filter(x=>hashMap.get(x)); + var values = hashMap.keys.getRef().data.filter(x => hashMap.get(x)); return qhash(entity, values, 127); } }).toString() + ")();";