add some flags

This commit is contained in:
ZXMushroom63 2024-12-29 23:29:41 +08:00
parent c6496fc672
commit 25e2d20789
4 changed files with 25 additions and 24 deletions

15
docs/config.md Normal file
View File

@ -0,0 +1,15 @@
## eaglercraftXopts and search parameters
### noInitialModGui
- `processed.html?noInitialModGui=true`
or inside eaglercraftXopts
disables the mod gui display on startup
### Adding mods
Set eaglercraftXopts.Mods to an array of mod urls.
You can also use search parameters, eg:
- `processed.html?mod=https://example.com/mod.js`
- `processed.html?mod=https://example.com/mod.js&mod=https://example.com/mod2.js`

View File

@ -10,4 +10,6 @@ EaglerForge Injector is a tool that uses regular expressions to attach itself to
[Modding API documentation](apidoc/index.md)
[Compiling the client for EaglerForgeInjector](compiling_client.md)
[Compiling the client for EaglerForgeInjector](compiling_client.md)
[eaglercraftXopts and search parameters](config.md)

View File

@ -296,11 +296,11 @@ var main;(function(){`
` id="game_frame">
\<script id="modapi_patchesreg_events"\>${PatchesRegistry.getEventInjectorCode()};\<\/script\>
\<script id="modapi_postinit"\>${globalThis.modapi_postinit.replace("__modapi_version_code__", ModAPIVersion)}\<\/script\>
\<script id="modapi_postinitasync"\>${globalThis.modapi_postinitasync}\<\/script\>
\<script id="modapi_modloader"\>${globalThis.modapi_modloader}\<\/script\>
\<script id="modapi_guikit"\>${globalThis.modapi_guikit}\<\/script\>
\<script id="modapi_postinit_data"\>globalThis.modapi_postinit = \`${globalThis.modapi_postinit}\`;\<\/script\>
\<script id="libserverside"\>{"._|_libserverside_|_."}\<\/script\>`
\<script id="libserverside"\>{"._|_libserverside_|_."}\<\/script\>
\<script id="__eaglerforgeinjector_installation_flag__"\>console.log("Thank you for using EaglerForge!");\<\/script\>`
);
patchedFile = patchedFile.replace(`<title>EaglercraftX 1.8</title>`, `<title>EFI ${globalThis.ModAPIVersion}</title>`);
patchedFile = patchedFile.replaceAll(/main\(\);\s*?}/gm, (match) => {

View File

@ -34,6 +34,10 @@ globalThis.modapi_postinit = "(" + (() => {
return x;
}
}
function getEaglerConfigFlag(key) {
var searchParams = new URLSearchParams(location.search);
return (globalThis.eaglercraftXOpts?.[key] || searchParams.get(key)) ? true : false
}
function easyStaticMethod(classId, methodName, autoUnpack) {
var method = ModAPI.reflect.getClassById(classId).staticMethods[methodName].method;
return function easyImpl(...args) {
@ -797,26 +801,6 @@ globalThis.modapi_postinit = "(" + (() => {
return sendChatMessage.apply(this, [$this, $message]);
}
// ModAPI.events.newEvent("render", "client");
// const renderMethodName = ModAPI.util.getMethodFromPackage("net.minecraft.client.renderer.EntityRenderer", "renderWorldPass");
// const renderMethod = ModAPI.hooks.methods[renderMethodName];
// ModAPI.hooks.methods[renderMethodName] = function ($this, $int_pass, $float_partialTicks, $long_finishTimeNano) {
// var shouldRenderHand = $this.$renderHand;
// $this.$renderHand = 0; //Rendering the hand clears the depth bit, which we don't want to do.
// var out = renderMethod.apply(this, [$this, $int_pass, $float_partialTicks, $long_finishTimeNano]);
// var data = {
// partialTicks: $float_partialTicks
// }
// ModAPI.events.callEvent("render", data);
// if (shouldRenderHand) {
// ModAPI.hooks.methods.nlevo_GlStateManager_clear(256); //GL_DEPTH_BUFFER_BIT, found in class RealOpenGLEnums
// ModAPI.hooks.methods.nmcr_EntityRenderer_renderHand($this, $float_partialTicks, $int_pass);
// ModAPI.hooks.methods.nmcr_EntityRenderer_renderWorldDirections($this, $float_partialTicks);
// }
// $this.$renderHand = shouldRenderHand;
// return out;
// }
const ScaledResolutionConstructor = ModAPI.reflect.getClassByName("ScaledResolution").constructors[0];
ModAPI.events.newEvent("frame", "client");
const frameMethodName = ModAPI.util.getMethodFromPackage("net.minecraft.client.Minecraft", "runTick");
@ -970,7 +954,7 @@ globalThis.modapi_postinit = "(" + (() => {
var x = originalCrashMethod.apply(this, args);
return x;
}
var inited = false;
var inited = getEaglerConfigFlag("noInitialModGui");
const originalMainMethod = ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.lax1dude.eaglercraft.v1_8.internal.teavm.ClientMain", "_main")];
ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.lax1dude.eaglercraft.v1_8.internal.teavm.ClientMain", "_main")] = function (...args) {
if (!inited) {