mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-24 14:41:18 -09:00
addCredits API
This commit is contained in:
parent
711263afec
commit
b0c8c09a60
@ -100,6 +100,8 @@ The ModAPI object has the following methods:
|
|||||||
- `promisify(asyncJavaMethod: Method | Constructor) : PromisifiedJavaRunner`
|
- `promisify(asyncJavaMethod: Method | Constructor) : PromisifiedJavaRunner`
|
||||||
- Allows running java methods that are @Async/@Async dependent.
|
- Allows running java methods that are @Async/@Async dependent.
|
||||||
- More [PromisifyDocumentation](promisify.md)
|
- 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.
|
## Handling strings, numbers and booleans to and from java.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
globalThis.ModAPIVersion = "v2.7.1";
|
globalThis.ModAPIVersion = "v2.7.2";
|
||||||
globalThis.doEaglerforge = true;
|
globalThis.doEaglerforge = true;
|
||||||
document.querySelector("title").innerText = `EaglerForge Injector ${ModAPIVersion}`;
|
document.querySelector("title").innerText = `EaglerForge Injector ${ModAPIVersion}`;
|
||||||
document.querySelector("h1").innerText = `EaglerForge Injector ${ModAPIVersion}`;
|
document.querySelector("h1").innerText = `EaglerForge Injector ${ModAPIVersion}`;
|
||||||
|
80
postinit.js
80
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.
|
//This script cannot contain backticks, escape characters, or backslashes in order to inject into the dedicated server code.
|
||||||
var startedModLoader = false;
|
var startedModLoader = false;
|
||||||
var BACKSLASH = String.fromCharCode(92);
|
var BACKSLASH = String.fromCharCode(92);
|
||||||
|
var LF = String.fromCharCode(10);
|
||||||
var STRIP_COMMENTS = new RegExp(atob("KChcL1wvLiokKXwoXC9cKltcc1xTXSo/XCpcLykp"), "gm");
|
var STRIP_COMMENTS = new RegExp(atob("KChcL1wvLiokKXwoXC9cKltcc1xTXSo/XCpcLykp"), "gm");
|
||||||
var ARGUMENT_NAMES = new RegExp(atob("KFteXHMsXSsp"), "g");
|
var ARGUMENT_NAMES = new RegExp(atob("KFteXHMsXSsp"), "g");
|
||||||
|
|
||||||
@ -24,12 +25,57 @@ globalThis.modapi_postinit = "(" + (() => {
|
|||||||
ModAPI.meta._developerMap = {};
|
ModAPI.meta._developerMap = {};
|
||||||
ModAPI.meta._iconMap = {};
|
ModAPI.meta._iconMap = {};
|
||||||
ModAPI.meta._versionMap = {};
|
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.array = {};
|
||||||
|
|
||||||
ModAPI.version = "__modapi_version_code__";
|
ModAPI.version = "__modapi_version_code__";
|
||||||
ModAPI.flavour = "injector";
|
ModAPI.flavour = "injector";
|
||||||
ModAPI.GNU = "terry pratchett";
|
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) {
|
function limitSize(x, n) {
|
||||||
if (x.length > n) {
|
if (x.length > n) {
|
||||||
@ -41,20 +87,20 @@ globalThis.modapi_postinit = "(" + (() => {
|
|||||||
function arraysAreSame(arr1, arr2) {
|
function arraysAreSame(arr1, arr2) {
|
||||||
if (!arr1 || !arr2)
|
if (!arr1 || !arr2)
|
||||||
return false;
|
return false;
|
||||||
if(arr1 === arr2)
|
if (arr1 === arr2)
|
||||||
return true;
|
return true;
|
||||||
if (arr1.length !== arr2.length)
|
if (arr1.length !== arr2.length)
|
||||||
return false;
|
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] instanceof Array && arr2[i] instanceof Array) {
|
||||||
if (!arr1[i].equals(arr2[i]))
|
if (!arr1[i].equals(arr2[i]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (arr1[i] !== arr2[i]) {
|
else if (arr1[i] !== arr2[i]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
function getParamNames(func) {
|
function getParamNames(func) {
|
||||||
@ -343,7 +389,7 @@ globalThis.modapi_postinit = "(" + (() => {
|
|||||||
"getConstructorByArgs": function (...argNames) {
|
"getConstructorByArgs": function (...argNames) {
|
||||||
if (!argumentCache) {
|
if (!argumentCache) {
|
||||||
argumentCache = [];
|
argumentCache = [];
|
||||||
this.internalConstructors.forEach(x=>{
|
this.internalConstructors.forEach(x => {
|
||||||
argumentCache.push(getParamNames(x).slice(1).map(y => y.substring(1)));
|
argumentCache.push(getParamNames(x).slice(1).map(y => y.substring(1)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -821,6 +867,22 @@ globalThis.modapi_postinit = "(" + (() => {
|
|||||||
return originalUpdate.apply(this, args);
|
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 initMethodName = ModAPI.util.getMethodFromPackage("net.minecraft.client.Minecraft", "startGame");
|
||||||
const originalInit = ModAPI.hooks.methods[initMethodName];
|
const originalInit = ModAPI.hooks.methods[initMethodName];
|
||||||
ModAPI.hooks.methods[initMethodName] = function (...args) {
|
ModAPI.hooks.methods[initMethodName] = function (...args) {
|
||||||
@ -1105,7 +1167,7 @@ globalThis.modapi_postinit = "(" + (() => {
|
|||||||
}
|
}
|
||||||
ModAPI.keygen.entity = function (entity) {
|
ModAPI.keygen.entity = function (entity) {
|
||||||
var hashMap = ModAPI.util.wrap(ModAPI.reflect.getClassById("net.minecraft.entity.EntityList").staticVariables.idToClassMapping).getCorrective();
|
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);
|
return qhash(entity, values, 127);
|
||||||
}
|
}
|
||||||
}).toString() + ")();";
|
}).toString() + ")();";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user