not quite done, but launch GUI before client (#5)

* Update modgui.js

* Update modgui.injector.js

* idk if u want this

* idk if u want this pt 2

* I cont beleive i forgor this

* forgor
This commit is contained in:
Stpv22 2024-09-18 02:01:44 -07:00 committed by GitHub
parent df75615ea7
commit 6aa24515ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 62 deletions

View File

@ -105,6 +105,11 @@ var main;(function(){`
\<script id="libserverside"\>{"._|_libserverside_|_."}\<\/script\>`
);
patchedFile = patchedFile.replace(
`document.getElementById("launch_countdown_screen").remove(); main();`,
`document.getElementById("launch_countdown_screen").remove(); window.modapi_displayModGui();`
)
const extractConstructorRegex =
/^\s*function (\S*?)__init_\d*?\((?!\$)/gm;
const extractConstructorFullNameRegex =

View File

@ -42,7 +42,7 @@ globalThis.modapi_guikit = `// ModAPI GUI made by TheIdiotPlays
<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>
<button class="button" onclick="this.parentElement.parentElement.remove(); main();">Done</button>
</div>
<span>(reload to apply changes)</span>
@ -159,6 +159,7 @@ globalThis.modapi_guikit = `// ModAPI GUI made by TheIdiotPlays
}
</style>
</div>\`;
async function fileToDataURI(file) {
return new Promise((res, rej) => {
var fr = new FileReader();

View File

@ -42,7 +42,7 @@
<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>
<button class="button" onclick="this.parentElement.parentElement.remove(); main();">Done</button>
</div>
<span>(reload to apply changes)</span>
@ -159,6 +159,7 @@
}
</style>
</div>`;
async function fileToDataURI(file) {
return new Promise((res, rej) => {
var fr = new FileReader();

View File

@ -741,35 +741,6 @@ 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?")) {
@ -778,4 +749,4 @@ globalThis.modapi_postinit = `(() => {
var x = originalCrashMethod.apply(this, args);
return x;
}
})();`;
})();`;

View File

@ -741,35 +741,6 @@
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?")) {
@ -778,4 +749,4 @@
var x = originalCrashMethod.apply(this, args);
return x;
}
})();
})();