mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-23 14:11:16 -09:00
Add example command, gui part 2
This commit is contained in:
parent
0935ed5096
commit
5c04ec22d0
15
examplemods/talkback.js
Normal file
15
examplemods/talkback.js
Normal file
@ -0,0 +1,15 @@
|
||||
(() => {
|
||||
PluginAPI.dedicatedServer.appendCode(function () {
|
||||
PluginAPI.addEventListener("processcommand", (event) => {
|
||||
if (event.command.toLowerCase().startsWith("/talkback")) {
|
||||
var message = event.command.substring("/talkback ".length);
|
||||
if (
|
||||
ModAPI.hooks._teavm.$rt_isInstance(event.sender, ModAPI.hooks._classMap[ModAPI.util.getCompiledName("net.minecraft.entity.player.EntityPlayerMP")].class)
|
||||
) {
|
||||
event.sender.addChatMessage(ModAPI.hooks._classMap[ModAPI.util.getCompiledName("net.minecraft.util.ChatComponentText")].constructors[0](ModAPI.util.str(message.toUpperCase())));
|
||||
}
|
||||
event.preventDefault = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
@ -262,5 +262,6 @@ var main;(function(){`
|
||||
<!-- Code assets -->
|
||||
<script src="postinit.injector.js"></script>
|
||||
<script src="modloader.injector.js"></script>
|
||||
<script src="modgui.injector.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1 +1,195 @@
|
||||
globalThis.modapi_guikit = ``;
|
||||
globalThis.modapi_guikit = `// ModAPI GUI made by TheIdiotPlays
|
||||
// https://github.com/TheIdiotPlays
|
||||
(()=>{
|
||||
var splashes = [
|
||||
"Now with A.I.D.S (automatically injected dedicated server)",
|
||||
"Only causes death 90% of the time!",
|
||||
"HTML is better.",
|
||||
"https://github.com/EaglerForge",
|
||||
"hey you should check out https://github.com/ZXMushroom63/scratch-gui",
|
||||
"99% of people stop gambling before they win big."
|
||||
];
|
||||
var gui = \`<div id="modapi_gui_container">
|
||||
<header>
|
||||
<h1 class="title">EaglerForge Mod Manager</h1>
|
||||
<h4>
|
||||
<!-- Now with with A.I.D.S. (automatically injected dedicated server)! -->
|
||||
{splash_msg}
|
||||
</h4>
|
||||
<h5>
|
||||
Warning: installing malicious mods can delete your worlds, ip-grab you, or even download more serious malware onto your computer. The EaglerForge developers are not liable for any damage caused by the use of EaglerForge and its related tools.
|
||||
</h5>
|
||||
</header>
|
||||
|
||||
<table class="modTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>
|
||||
URL
|
||||
</td>
|
||||
<td class="nothing"></td>
|
||||
<td>
|
||||
Controls
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="controls">
|
||||
<button class="button" onclick="window.modapi_uploadmod()">Upload Mod (.js)</button>
|
||||
<button class="button" onclick="window.modapi_addmod()">Add Mod From URL</button>
|
||||
<button class="button" style="text-shadow: 0px 0px 10px rgba(255, 0, 0, 0.5)" onclick="window.modapi_clearmods()">Clear All Mods</button>
|
||||
<button class="button" onclick="this.parentElement.parentElement.remove();">Done</button>
|
||||
</div>
|
||||
|
||||
<span>(reload to apply changes)</span>
|
||||
|
||||
<footer>
|
||||
<p>
|
||||
GUI by <a href="https://github.com/TheIdiotPlays">TheIdiotPlays</a>
|
||||
</p>
|
||||
<p>
|
||||
Modloader linker by
|
||||
<a href="https://github.com/ZXMushroom63">ZXMushroom63</a>
|
||||
</p>
|
||||
</footer>
|
||||
|
||||
<style>
|
||||
#modapi_gui_container td:not(.nothing):not(:has(.button)) {
|
||||
padding: 0.5rem 1.5rem;
|
||||
margin: 0.5rem;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
#modapi_gui_container td.nothing {
|
||||
user-select: none;
|
||||
opacity: 0;
|
||||
width: 5rem;
|
||||
}
|
||||
#modapi_gui_container td {
|
||||
text-align: center;
|
||||
}
|
||||
#modapi_gui_container h4, #modapi_gui_container h5 {
|
||||
padding-bottom: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
#modapi_gui_container h5 {
|
||||
color: white;
|
||||
text-shadow: 0px 0px 10px rgba(255,0,0,0.5);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
#modapi_gui_container a {
|
||||
color: white;
|
||||
transition: 1s;
|
||||
}
|
||||
#modapi_gui_container a:hover {
|
||||
color: lightblue;
|
||||
}
|
||||
|
||||
#modapi_gui_container {
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
position: fixed;
|
||||
z-index: 9999999999;
|
||||
top: 0;
|
||||
left: 0;
|
||||
font-family: sans-serif;
|
||||
background: white;
|
||||
}
|
||||
|
||||
#modapi_gui_container header {
|
||||
background-color: #333;
|
||||
width: 100%;
|
||||
padding: 1rem 0;
|
||||
text-align: center;
|
||||
color: white;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
#modapi_gui_container .title {
|
||||
font-size: 3rem;
|
||||
margin: 0;
|
||||
font-weight: 700;
|
||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
#modapi_gui_container .controls {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
margin-bottom: 2rem;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#modapi_gui_container .button {
|
||||
background-color: #555;
|
||||
color: white;
|
||||
padding: 12px 24px;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
border: none;
|
||||
border-radius: 2px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s ease, transform 0.2s ease;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
#modapi_gui_container .button:hover {
|
||||
background-color: #777;
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
#modapi_gui_container footer {
|
||||
width: 100%;
|
||||
padding: 1rem;
|
||||
background-color: #333;
|
||||
text-align: center;
|
||||
color: white;
|
||||
font-size: 1.25rem;
|
||||
box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
</style>
|
||||
</div>\`;
|
||||
window.modapi_displayModGui = async function () {
|
||||
if (!getMods) {
|
||||
return;
|
||||
}
|
||||
if (document.querySelector("#modapi_gui_container")) {
|
||||
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);
|
||||
|
||||
var modsList = await getMods();
|
||||
var tbody = document.querySelector("#modapi_gui_container .modTable tbody");
|
||||
tbody.innerHTML = "";
|
||||
modsList.forEach((modtxt, i) => {
|
||||
var tr = document.createElement("tr");
|
||||
var mod = document.createElement("td");
|
||||
mod.innerText = modtxt;
|
||||
var spacer = document.createElement("td");
|
||||
spacer.appendChild("nothing");
|
||||
var controls = document.createElement("td");
|
||||
|
||||
var button = document.createElement("button");
|
||||
button.classList.add("button");
|
||||
controls.appendChild(button);
|
||||
tr.appendChild(mod);
|
||||
tr.appendChild(spacer);
|
||||
tr.appendChild(button);
|
||||
tbody.appendChild(tr);
|
||||
});
|
||||
|
||||
}
|
||||
})();`;
|
193
modgui.js
193
modgui.js
@ -1,2 +1,195 @@
|
||||
// ModAPI GUI made by TheIdiotPlays
|
||||
// https://github.com/TheIdiotPlays
|
||||
(()=>{
|
||||
var splashes = [
|
||||
"Now with A.I.D.S (automatically injected dedicated server)",
|
||||
"Only causes death 90% of the time!",
|
||||
"HTML is better.",
|
||||
"https://github.com/EaglerForge",
|
||||
"hey you should check out https://github.com/ZXMushroom63/scratch-gui",
|
||||
"99% of people stop gambling before they win big."
|
||||
];
|
||||
var gui = `<div id="modapi_gui_container">
|
||||
<header>
|
||||
<h1 class="title">EaglerForge Mod Manager</h1>
|
||||
<h4>
|
||||
<!-- Now with with A.I.D.S. (automatically injected dedicated server)! -->
|
||||
{splash_msg}
|
||||
</h4>
|
||||
<h5>
|
||||
Warning: installing malicious mods can delete your worlds, ip-grab you, or even download more serious malware onto your computer. The EaglerForge developers are not liable for any damage caused by the use of EaglerForge and its related tools.
|
||||
</h5>
|
||||
</header>
|
||||
|
||||
<table class="modTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>
|
||||
URL
|
||||
</td>
|
||||
<td class="nothing"></td>
|
||||
<td>
|
||||
Controls
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="controls">
|
||||
<button class="button" onclick="window.modapi_uploadmod()">Upload Mod (.js)</button>
|
||||
<button class="button" onclick="window.modapi_addmod()">Add Mod From URL</button>
|
||||
<button class="button" style="text-shadow: 0px 0px 10px rgba(255, 0, 0, 0.5)" onclick="window.modapi_clearmods()">Clear All Mods</button>
|
||||
<button class="button" onclick="this.parentElement.parentElement.remove();">Done</button>
|
||||
</div>
|
||||
|
||||
<span>(reload to apply changes)</span>
|
||||
|
||||
<footer>
|
||||
<p>
|
||||
GUI by <a href="https://github.com/TheIdiotPlays">TheIdiotPlays</a>
|
||||
</p>
|
||||
<p>
|
||||
Modloader linker by
|
||||
<a href="https://github.com/ZXMushroom63">ZXMushroom63</a>
|
||||
</p>
|
||||
</footer>
|
||||
|
||||
<style>
|
||||
#modapi_gui_container td:not(.nothing):not(:has(.button)) {
|
||||
padding: 0.5rem 1.5rem;
|
||||
margin: 0.5rem;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
#modapi_gui_container td.nothing {
|
||||
user-select: none;
|
||||
opacity: 0;
|
||||
width: 5rem;
|
||||
}
|
||||
#modapi_gui_container td {
|
||||
text-align: center;
|
||||
}
|
||||
#modapi_gui_container h4, #modapi_gui_container h5 {
|
||||
padding-bottom: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
#modapi_gui_container h5 {
|
||||
color: white;
|
||||
text-shadow: 0px 0px 10px rgba(255,0,0,0.5);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
#modapi_gui_container a {
|
||||
color: white;
|
||||
transition: 1s;
|
||||
}
|
||||
#modapi_gui_container a:hover {
|
||||
color: lightblue;
|
||||
}
|
||||
|
||||
#modapi_gui_container {
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
position: fixed;
|
||||
z-index: 9999999999;
|
||||
top: 0;
|
||||
left: 0;
|
||||
font-family: sans-serif;
|
||||
background: white;
|
||||
}
|
||||
|
||||
#modapi_gui_container header {
|
||||
background-color: #333;
|
||||
width: 100%;
|
||||
padding: 1rem 0;
|
||||
text-align: center;
|
||||
color: white;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
#modapi_gui_container .title {
|
||||
font-size: 3rem;
|
||||
margin: 0;
|
||||
font-weight: 700;
|
||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
#modapi_gui_container .controls {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
margin-bottom: 2rem;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#modapi_gui_container .button {
|
||||
background-color: #555;
|
||||
color: white;
|
||||
padding: 12px 24px;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
border: none;
|
||||
border-radius: 2px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s ease, transform 0.2s ease;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
#modapi_gui_container .button:hover {
|
||||
background-color: #777;
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
#modapi_gui_container footer {
|
||||
width: 100%;
|
||||
padding: 1rem;
|
||||
background-color: #333;
|
||||
text-align: center;
|
||||
color: white;
|
||||
font-size: 1.25rem;
|
||||
box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
</style>
|
||||
</div>`;
|
||||
window.modapi_displayModGui = async function () {
|
||||
if (!getMods) {
|
||||
return;
|
||||
}
|
||||
if (document.querySelector("#modapi_gui_container")) {
|
||||
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);
|
||||
|
||||
var modsList = await getMods();
|
||||
var tbody = document.querySelector("#modapi_gui_container .modTable tbody");
|
||||
tbody.innerHTML = "";
|
||||
modsList.forEach((modtxt, i) => {
|
||||
var tr = document.createElement("tr");
|
||||
var mod = document.createElement("td");
|
||||
mod.innerText = modtxt;
|
||||
var spacer = document.createElement("td");
|
||||
spacer.appendChild("nothing");
|
||||
var controls = document.createElement("td");
|
||||
|
||||
var button = document.createElement("button");
|
||||
button.classList.add("button");
|
||||
controls.appendChild(button);
|
||||
tr.appendChild(mod);
|
||||
tr.appendChild(spacer);
|
||||
tr.appendChild(button);
|
||||
tbody.appendChild(tr);
|
||||
});
|
||||
|
||||
}
|
||||
})();
|
@ -5,29 +5,48 @@ globalThis.modapi_modloader = `function promisifyIDBRequest(request) {
|
||||
});
|
||||
}
|
||||
|
||||
async function getDatabase() {
|
||||
const dbRequest = indexedDB.open("EF_MODS");
|
||||
const db = await promisifyIDBRequest(dbRequest);
|
||||
|
||||
if (!db.objectStoreNames.contains("filesystem")) {
|
||||
db.close();
|
||||
const version = db.version + 1;
|
||||
const upgradeRequest = indexedDB.open("EF_MODS", version);
|
||||
upgradeRequest.onupgradeneeded = (event) => {
|
||||
const upgradedDb = event.target.result;
|
||||
upgradedDb.createObjectStore("filesystem");
|
||||
};
|
||||
return promisifyIDBRequest(upgradeRequest);
|
||||
}
|
||||
|
||||
return db;
|
||||
}
|
||||
|
||||
async function getMods() {
|
||||
const db = await promisifyIDBRequest(indexedDB.open("EF_MODS"));
|
||||
const transaction = db.transaction(["filesystem"], "readwrite");
|
||||
const db = await getDatabase();
|
||||
const transaction = db.transaction(["filesystem"], "readonly");
|
||||
const objectStore = transaction.objectStore("filesystem");
|
||||
const object = await promisifyIDBRequest(objectStore.get(["mods.txt"]));
|
||||
const object = await promisifyIDBRequest(objectStore.get("mods.txt"));
|
||||
const decoder = new TextDecoder("utf-8");
|
||||
return object ? decoder.decode(object.data).split("|") : [];
|
||||
return object ? decoder.decode(object).split("|") : [];
|
||||
}
|
||||
|
||||
async function saveMods(mods) {
|
||||
const db = await promisifyIDBRequest(indexedDB.open("EF_MODS"));
|
||||
const db = await getDatabase();
|
||||
const transaction = db.transaction(["filesystem"], "readwrite");
|
||||
const objectStore = transaction.objectStore("filesystem");
|
||||
const encoder = new TextEncoder();
|
||||
const modsData = encoder.encode(mods.join("|"));
|
||||
const modsBlob = new Blob([modsData], { type: "text/plain" });
|
||||
await promisifyIDBRequest(objectStore.put({ data: modsBlob }, ["mods.txt"]));
|
||||
await promisifyIDBRequest(objectStore.put(modsBlob, "mods.txt"));
|
||||
}
|
||||
|
||||
async function addMod(mod) {
|
||||
const mods = await getMods();
|
||||
mods.push(mod);
|
||||
await saveMods(mods);
|
||||
console.log("Mod added: " + mod);
|
||||
}
|
||||
|
||||
async function removeMod(index) {
|
||||
@ -35,11 +54,15 @@ async function removeMod(index) {
|
||||
if (index >= 0 && index < mods.length) {
|
||||
const removedMod = mods.splice(index, 1);
|
||||
await saveMods(mods);
|
||||
console.log("Mod removed: " + removedMod);
|
||||
} else {
|
||||
console.log("Invalid index");
|
||||
}
|
||||
}
|
||||
|
||||
async function resetMods() {
|
||||
await saveMods([]);
|
||||
console.log("Mods reset");
|
||||
}
|
||||
|
||||
window.modLoader = async function modLoader(modsArr) {
|
||||
@ -154,7 +177,7 @@ window.modLoader = async function modLoader(modsArr) {
|
||||
console.log("[EaglerML] Loading " + currentMod + " via method B.");
|
||||
var script = document.createElement("script");
|
||||
script.src = currentMod;
|
||||
script.setAttribute("data-Mod", currentMod);
|
||||
script.setAttribute("data-mod", currentMod);
|
||||
script.setAttribute("data-isMod", true);
|
||||
script.onerror = () => {
|
||||
console.log(
|
||||
@ -196,7 +219,7 @@ window.modLoader = async function modLoader(modsArr) {
|
||||
methodB(currentMod);
|
||||
return;
|
||||
}
|
||||
script.setAttribute("data-Mod", currentMod);
|
||||
script.setAttribute("data-mod", currentMod);
|
||||
script.setAttribute("data-isMod", true);
|
||||
script.onerror = () => {
|
||||
console.log(
|
||||
|
35
modloader.js
35
modloader.js
@ -5,29 +5,48 @@ function promisifyIDBRequest(request) {
|
||||
});
|
||||
}
|
||||
|
||||
async function getDatabase() {
|
||||
const dbRequest = indexedDB.open("EF_MODS");
|
||||
const db = await promisifyIDBRequest(dbRequest);
|
||||
|
||||
if (!db.objectStoreNames.contains("filesystem")) {
|
||||
db.close();
|
||||
const version = db.version + 1;
|
||||
const upgradeRequest = indexedDB.open("EF_MODS", version);
|
||||
upgradeRequest.onupgradeneeded = (event) => {
|
||||
const upgradedDb = event.target.result;
|
||||
upgradedDb.createObjectStore("filesystem");
|
||||
};
|
||||
return promisifyIDBRequest(upgradeRequest);
|
||||
}
|
||||
|
||||
return db;
|
||||
}
|
||||
|
||||
async function getMods() {
|
||||
const db = await promisifyIDBRequest(indexedDB.open("EF_MODS"));
|
||||
const transaction = db.transaction(["filesystem"], "readwrite");
|
||||
const db = await getDatabase();
|
||||
const transaction = db.transaction(["filesystem"], "readonly");
|
||||
const objectStore = transaction.objectStore("filesystem");
|
||||
const object = await promisifyIDBRequest(objectStore.get(["mods.txt"]));
|
||||
const object = await promisifyIDBRequest(objectStore.get("mods.txt"));
|
||||
const decoder = new TextDecoder("utf-8");
|
||||
return object ? decoder.decode(object.data).split("|") : [];
|
||||
return object ? decoder.decode(object).split("|") : [];
|
||||
}
|
||||
|
||||
async function saveMods(mods) {
|
||||
const db = await promisifyIDBRequest(indexedDB.open("EF_MODS"));
|
||||
const db = await getDatabase();
|
||||
const transaction = db.transaction(["filesystem"], "readwrite");
|
||||
const objectStore = transaction.objectStore("filesystem");
|
||||
const encoder = new TextEncoder();
|
||||
const modsData = encoder.encode(mods.join("|"));
|
||||
const modsBlob = new Blob([modsData], { type: "text/plain" });
|
||||
await promisifyIDBRequest(objectStore.put({ data: modsBlob }, ["mods.txt"]));
|
||||
await promisifyIDBRequest(objectStore.put(modsBlob, "mods.txt"));
|
||||
}
|
||||
|
||||
async function addMod(mod) {
|
||||
const mods = await getMods();
|
||||
mods.push(mod);
|
||||
await saveMods(mods);
|
||||
console.log("Mod added: " + mod);
|
||||
}
|
||||
|
||||
async function removeMod(index) {
|
||||
@ -35,11 +54,15 @@ async function removeMod(index) {
|
||||
if (index >= 0 && index < mods.length) {
|
||||
const removedMod = mods.splice(index, 1);
|
||||
await saveMods(mods);
|
||||
console.log("Mod removed: " + removedMod);
|
||||
} else {
|
||||
console.log("Invalid index");
|
||||
}
|
||||
}
|
||||
|
||||
async function resetMods() {
|
||||
await saveMods([]);
|
||||
console.log("Mods reset");
|
||||
}
|
||||
|
||||
window.modLoader = async function modLoader(modsArr) {
|
||||
|
@ -1,6 +1,15 @@
|
||||
globalThis.modapi_postinit = `(() => {
|
||||
//EaglerForge post initialization code.
|
||||
//This script cannot contain backticks, escape characters, or backslashes in order to inject into the dedicated server code.
|
||||
var startedModLoader = false;
|
||||
|
||||
function startModLoader() {
|
||||
if (!startedModLoader) {
|
||||
startedModLoader = true;
|
||||
modLoader([]);
|
||||
}
|
||||
}
|
||||
|
||||
ModAPI.hooks._classMap = {};
|
||||
globalThis.PluginAPI ||= ModAPI;
|
||||
ModAPI.mcinstance ||= {};
|
||||
@ -294,7 +303,7 @@ globalThis.modapi_postinit = `(() => {
|
||||
}
|
||||
};
|
||||
ModAPI.events.newEvent = function newEvent(name, side) {
|
||||
console.log("[ModAPI] Registered "+side+" event: "+name);
|
||||
console.log("[ModAPI] Registered " + side + " event: " + name);
|
||||
ModAPI.events.types.push(name);
|
||||
};
|
||||
|
||||
@ -390,6 +399,9 @@ globalThis.modapi_postinit = `(() => {
|
||||
//args[0] means $this (ie: minecraft instance).
|
||||
ModAPI.mcinstance = ModAPI.javaClient = args[0];
|
||||
ModAPI.settings = new Proxy(ModAPI.mcinstance.$gameSettings, TeaVM_to_Recursive_BaseData_ProxyConf);
|
||||
|
||||
startModLoader();
|
||||
|
||||
return x;
|
||||
};
|
||||
|
||||
@ -497,4 +509,33 @@ globalThis.modapi_postinit = `(() => {
|
||||
|
||||
ModAPI.items = new Proxy(ModAPI.hooks._classMap[ModAPI.util.getCompiledName("net.minecraft.init.Items")].staticVariables, StaticProps_ProxyConf);
|
||||
ModAPI.blocks = new Proxy(ModAPI.hooks._classMap[ModAPI.util.getCompiledName("net.minecraft.init.Blocks")].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.05 ? "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;
|
||||
}
|
||||
})();`;
|
Loading…
x
Reference in New Issue
Block a user