mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-26 15:29:26 -09:00
Merge pull request #9 from eaglerforge/main
Update stable to latest changes
This commit is contained in:
commit
530bd2f2bd
@ -1,6 +1,17 @@
|
||||
# EaglerForge ModAPI Documentation
|
||||
The EaglerForge ModAPI is housed in a global JavaScript object stored on `globalThis`, called `ModAPI` or `PluginAPI`. (both are identical)
|
||||
|
||||
### Important Notice!
|
||||
From people used to the doc prior to EaglerForgeInjector, now, when you see something like `ModAPI.world`'s type is `World`, that literally means it is identical to an instance of `net.minecraft.world.World` from java. For easier modding, here are some online javadocs, that explain properties from each individual method and proerty of every 1.8 class:
|
||||
|
||||
https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/overview-summary.html - Javadoc for vanilla 1.8
|
||||
https://eaglerreborn.github.io/javadoc/ - EaglerReborn (EF precursor) javadoc, for EaglercraftX u17 (missing serverside classes, this version didn't have singleplayer)
|
||||
An up-to-date javadoc for EaglercraftX is coming soon, in the meanwhile, I recommend modding with a local EaglercraftX workspace, so you can inspect the contents of each class.
|
||||
|
||||
Additionally, when you se that something like `ModAPI.mcinstance` is `Raw<Minecraft>` this means that it has a lot of TeaVM nonsense like '$' prefixes before everything, as well has making it difficult to call the objects methods.
|
||||
|
||||
### Global ModAPI Object:
|
||||
|
||||
The global object has the following properties:
|
||||
- `ModAPI.player: EntityPlayerSP`
|
||||
- Only accessible after `ModAPI.require("player")` is called, this is the local player entity. It is regenerated every time the `update` event is called.
|
||||
|
@ -9,12 +9,16 @@
|
||||
|
||||
// Create a fake player GameProfile
|
||||
const GameProfileClass = ModAPI.reflect.getClassById("net.lax1dude.eaglercraft.v1_8.mojang.authlib.GameProfile");
|
||||
const fakeProfile = GameProfileClass.constructors[2](null, ModAPI.util.str("Steve"));
|
||||
const fakeProfile = GameProfileClass.constructors[1](null, ModAPI.util.str("Steve"));
|
||||
|
||||
// Get the PlayerInteractionManager class
|
||||
const PlayerInteractionManagerClass = ModAPI.reflect.getClassById("net.minecraft.server.management.ItemInWorldManager");
|
||||
const playerInteractionManager = PlayerInteractionManagerClass.constructors[0](world.getRef());
|
||||
|
||||
// Get the EntityPlayerMP class to spawn the fake player
|
||||
const EntityPlayerMPClass = ModAPI.reflect.getClassById("net.minecraft.entity.player.EntityPlayerMP");
|
||||
const fakePlayer = EntityPlayerMPClass.constructors[1](
|
||||
world.getMinecraftServer(), world.getRef(), fakeProfile, world.getPlayerInteractionManager()
|
||||
const fakePlayer = EntityPlayerMPClass.constructors[0](
|
||||
world.getMinecraftServer(), world.getRef(), fakeProfile, playerInteractionManager
|
||||
);
|
||||
|
||||
// Set the fake player position to be near the command sender
|
||||
|
@ -173,14 +173,18 @@ globalThis.modapi_guikit = `// ModAPI GUI made by TheIdiotPlays
|
||||
return;
|
||||
}
|
||||
if (document.querySelector("#modapi_gui_container")) {
|
||||
cb ||= document.querySelector("#modapi_gui_container")._cb;
|
||||
document.querySelector("#modapi_gui_container").remove();
|
||||
}
|
||||
|
||||
var element = document.createElement("div");
|
||||
|
||||
element.innerHTML = gui.replace("{splash_msg}", splashes[Math.floor(Math.random() * splashes.length)]);
|
||||
|
||||
document.body.appendChild(element);
|
||||
|
||||
document.querySelector("#modapi_gui_container")._cb = cb;
|
||||
|
||||
var modsList = await getMods();
|
||||
var tbody = document.querySelector("#modapi_gui_container .modTable tbody");
|
||||
tbody.innerHTML = "";
|
||||
|
@ -173,14 +173,18 @@
|
||||
return;
|
||||
}
|
||||
if (document.querySelector("#modapi_gui_container")) {
|
||||
cb ||= document.querySelector("#modapi_gui_container")._cb;
|
||||
document.querySelector("#modapi_gui_container").remove();
|
||||
}
|
||||
|
||||
var element = document.createElement("div");
|
||||
|
||||
element.innerHTML = gui.replace("{splash_msg}", splashes[Math.floor(Math.random() * splashes.length)]);
|
||||
|
||||
document.body.appendChild(element);
|
||||
|
||||
document.querySelector("#modapi_gui_container")._cb = cb;
|
||||
|
||||
var modsList = await getMods();
|
||||
var tbody = document.querySelector("#modapi_gui_container .modTable tbody");
|
||||
tbody.innerHTML = "";
|
||||
|
@ -741,6 +741,34 @@ globalThis.modapi_postinit = `(() => {
|
||||
ModAPI.materials = new Proxy(ModAPI.hooks._classMap[ModAPI.util.getCompiledName("net.minecraft.block.material.Material")].staticVariables, StaticProps_ProxyConf);
|
||||
ModAPI.enchantments = new Proxy(ModAPI.hooks._classMap[ModAPI.util.getCompiledName("net.minecraft.enchantment.Enchantment")].staticVariables, StaticProps_ProxyConf);
|
||||
|
||||
const originalOptionsInit = ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.gui.GuiOptions", "initGui")];
|
||||
ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.gui.GuiOptions", "initGui")] = function (...args) {
|
||||
var x = originalOptionsInit.apply(this, args);
|
||||
|
||||
//NOT A BUG DO NOT FIX
|
||||
var msg = Math.random() < 0.025 ? "Plugins" : "Mods";
|
||||
|
||||
// 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 btn = btnConstructor(9635329, 0, args[0].$height8 - 21, 100, 20, ModAPI.util.str(msg));
|
||||
args[0].$buttonList.$add(btn);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (args[1] && args[1].$id12 === 9635329) {
|
||||
if (typeof window.modapi_displayModGui === "function") {
|
||||
window.modapi_displayModGui();
|
||||
} else {
|
||||
alert("[ModAPI] Mod Manager GUI does not exist!")
|
||||
}
|
||||
}
|
||||
var x = originalOptionsAction.apply(this, args);
|
||||
return x;
|
||||
}
|
||||
|
||||
const originalCrashMethod = ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.lax1dude.eaglercraft.v1_8.internal.teavm.ClientMain", "showCrashScreen")];
|
||||
ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.lax1dude.eaglercraft.v1_8.internal.teavm.ClientMain", "showCrashScreen")] = function (...args) {
|
||||
if (window.confirm("Your game has crashed, do you want to open the mod manager gui?")) {
|
||||
|
28
postinit.js
28
postinit.js
@ -741,6 +741,34 @@
|
||||
ModAPI.materials = new Proxy(ModAPI.hooks._classMap[ModAPI.util.getCompiledName("net.minecraft.block.material.Material")].staticVariables, StaticProps_ProxyConf);
|
||||
ModAPI.enchantments = new Proxy(ModAPI.hooks._classMap[ModAPI.util.getCompiledName("net.minecraft.enchantment.Enchantment")].staticVariables, StaticProps_ProxyConf);
|
||||
|
||||
const originalOptionsInit = ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.gui.GuiOptions", "initGui")];
|
||||
ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.gui.GuiOptions", "initGui")] = function (...args) {
|
||||
var x = originalOptionsInit.apply(this, args);
|
||||
|
||||
//NOT A BUG DO NOT FIX
|
||||
var msg = Math.random() < 0.025 ? "Plugins" : "Mods";
|
||||
|
||||
// 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 btn = btnConstructor(9635329, 0, args[0].$height8 - 21, 100, 20, ModAPI.util.str(msg));
|
||||
args[0].$buttonList.$add(btn);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (args[1] && args[1].$id12 === 9635329) {
|
||||
if (typeof window.modapi_displayModGui === "function") {
|
||||
window.modapi_displayModGui();
|
||||
} else {
|
||||
alert("[ModAPI] Mod Manager GUI does not exist!")
|
||||
}
|
||||
}
|
||||
var x = originalOptionsAction.apply(this, args);
|
||||
return x;
|
||||
}
|
||||
|
||||
const originalCrashMethod = ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.lax1dude.eaglercraft.v1_8.internal.teavm.ClientMain", "showCrashScreen")];
|
||||
ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.lax1dude.eaglercraft.v1_8.internal.teavm.ClientMain", "showCrashScreen")] = function (...args) {
|
||||
if (window.confirm("Your game has crashed, do you want to open the mod manager gui?")) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user