From 0cc8f5292118b6f7c7074b01f4833826bed21a73 Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Fri, 25 Apr 2025 15:04:31 +0800 Subject: [PATCH 01/10] fix entity keygen on 1.12 --- core/postinit.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/core/postinit.js b/core/postinit.js index f6d252a..45b05e3 100644 --- a/core/postinit.js +++ b/core/postinit.js @@ -1172,7 +1172,7 @@ const modapi_postinit = "(" + (() => { ModAPI.util.getBlockById = easyStaticMethod("net.minecraft.block.Block", "getBlockById", false); ModAPI.util.getBlockFromItem = easyStaticMethod("net.minecraft.block.Block", "getBlockFromItem", true); ModAPI.util.getIdFromBlock = easyStaticMethod("net.minecraft.block.Block", "getIdFromBlock", true); - + function qhash(txt, arr, interval) { // var interval = 4095; //used to be 4095 - arr.length, but that increases incompatibility based on load order and other circumstances if (arr.length >= interval) { @@ -1210,8 +1210,18 @@ const modapi_postinit = "(" + (() => { return qhash(block, values, 4095); } ModAPI.keygen.entity = function (entity) { - 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 = []; + if (ModAPI.is_1_12) { + var arrayList = ModAPI.util.wrap(ModAPI.reflect.getClassById("net.minecraft.entity.EntityList").staticVariables.field_191311_g).getCorrective().array; + arrayList.forEach((x, i) => { + if (x) { + values.push(i); + } + }); + } else { + var hashMap = ModAPI.util.wrap(ModAPI.reflect.getClassById("net.minecraft.entity.EntityList").staticVariables.idToClassMapping).getCorrective(); + values = hashMap.keys.getRef().data.filter(x => hashMap.get(x)); + } return qhash(entity, values, 127); } }).toString() + ")();"; From 944688f20ffe140ba7fe6969d0c554e841564834 Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Fri, 25 Apr 2025 16:05:57 +0800 Subject: [PATCH 02/10] asyncsink 1.12 partially complete --- examplemods/AsyncSink.js | 95 ++++++++++++++++++++++++++++------------ 1 file changed, 67 insertions(+), 28 deletions(-) diff --git a/examplemods/AsyncSink.js b/examplemods/AsyncSink.js index abb02a2..78b0b2e 100644 --- a/examplemods/AsyncSink.js +++ b/examplemods/AsyncSink.js @@ -16,9 +16,9 @@ ModAPI.meta.credits("By ZXMushroom63"); } var fs_debugging = false; const encoder = new TextEncoder('utf-8'); - var filesystemPlatform = ModAPI.hooks.methods.nlevit_IndexedDBFilesystem$AsyncHandlers_readWholeFile ? true : false; + var filesystemPlatform = (ModAPI.hooks.methods.nlevit_IndexedDBFilesystem$AsyncHandlers_readWholeFile || ModAPI.hooks.methods.nleit_IndexedDBFilesystem$AsyncHandlers_readWholeFile) ? true : false; if (!filesystemPlatform) { - console.error("AsyncSink requires EaglercraftX u37 or greater to work! Attempting to run anyway..."); + console.warn("AsyncSink requires EaglercraftX u37 or greater to work! Attempting to run anyway..."); } const AsyncSink = {}; const originalSuspend = ModAPI.hooks.TeaVMThread.prototype.suspend; @@ -209,7 +209,7 @@ ModAPI.meta.credits("By ZXMushroom63"); async function assureAsyncSinkResources() { const dec = new TextDecoder("utf-8"); const enc = new TextEncoder("utf-8"); - var resourcePackKey = (await indexedDB.databases()).find(x => x?.name?.endsWith("_resourcePacks")).name; + var resourcePackKey = ModAPI.is_1_12 ? "_net_lax1dude_eaglercraft_v1_8_internal_PlatformFilesystem_1_12_2_" :(await indexedDB.databases()).find(x => x?.name?.endsWith("_resourcePacks")).name; const dbRequest = indexedDB.open(resourcePackKey); const db = await promisifyIDBRequest(dbRequest); const transaction = db.transaction(["filesystem"], "readonly"); @@ -242,7 +242,7 @@ ModAPI.meta.credits("By ZXMushroom63"); path: "resourcepacks/AsyncSinkLib/pack.mcmeta", data: enc.encode(JSON.stringify({ "pack": { - "pack_format": 1, + "pack_format": ModAPI.is_1_12 ? 3 : 1, "description": "AsyncSink Library Resources" } })).buffer @@ -307,7 +307,7 @@ ModAPI.meta.credits("By ZXMushroom63"); return; } var snd = ModAPI.mc.mcSoundHandler; - var registry = snd.sndRegistry.soundRegistry; + var registry = (snd.sndRegistry || snd.soundRegistry).getCorrective().soundRegistry; console.log("[AsyncSink] Populating sound registry hash map with " + AsyncSink.Audio.Objects.length + " sound effects."); AsyncSink.Audio.Objects.forEach(pair => { registry.put(pair[0], pair[1]); @@ -318,18 +318,19 @@ ModAPI.meta.credits("By ZXMushroom63"); // values = SoundEntry[] // category: AsyncSink.Audio.Category.* // SoundEntry = {path: String, pitch: 1, volume: 1, streaming: false} - const SoundPoolEntry = ModAPI.reflect.getClassByName("SoundPoolEntry").constructors.find(x => x.length === 4); const EaglercraftRandom = ModAPI.reflect.getClassByName("EaglercraftRandom").constructors.find(x=>x.length===0); - const SoundEventAccessorClass = ModAPI.reflect.getClassByName("SoundEventAccessor").class; + function makeSoundEventAccessor(soundpoolentry, weight) { + const SoundEventAccessorClass = ModAPI.reflect.getClassByName("SoundEventAccessor").class; var object = new SoundEventAccessorClass; var wrapped = ModAPI.util.wrap(object).getCorrective(); wrapped.entry = soundpoolentry; wrapped.weight = weight; return object; } - const SoundEventAccessorCompositeClass = ModAPI.reflect.getClassByName("SoundEventAccessorComposite").class; + function makeSoundEventAccessorComposite(rKey, pitch, volume, category) { + const SoundEventAccessorCompositeClass = ModAPI.reflect.getClassByName("SoundEventAccessorComposite").class; var object = new SoundEventAccessorCompositeClass; var wrapped = ModAPI.util.wrap(object).getCorrective(); wrapped.soundLocation = rKey; @@ -340,26 +341,64 @@ ModAPI.meta.credits("By ZXMushroom63"); wrapped.rnd = EaglercraftRandom(); return object; } - AsyncSink.Audio.register = function addSfx(key, category, values) { - if (!category) { - throw new Error("[AsyncSink] Invalid audio category provided: "+category); + function makeSoundEventAccessor112(rKey) { + const SoundEventAccessorClass = ModAPI.reflect.getClassByName("SoundEventAccessor").class; + var object = new SoundEventAccessorClass; + var wrapped = ModAPI.util.wrap(object).getCorrective(); + wrapped.location = rKey; + wrapped.subtitle = null; + wrapped.accessorList = ModAPI.hooks.methods.cgcc_Lists_newArrayList0(); + wrapped.rnd = EaglercraftRandom(); + return object; + } + if (ModAPI.is_1_12) { + const soundType = ModAPI.reflect.getClassById("net.minecraft.client.audio.Sound$Type").staticVariables.FILE; + const mkSound = ModAPI.reflect.getClassById("net.minecraft.client.audio.Sound").constructors[0]; + + AsyncSink.Audio.register = function addSfx(key, category, values) { + if (!category) { + throw new Error("[AsyncSink] Invalid audio category provided: "+category); + } + var snd = ModAPI.mc.mcSoundHandler.getCorrective(); + var registry = snd.soundRegistry.soundRegistry; + var rKey = ResourceLocation(ModAPI.util.str(key)); + var soundPool = values.map(se => { + return mkSound(ModAPI.util.str(se.path), se.volume, se.pitch, 1, soundType, 1 * se.streaming); + }); + var eventAccessor = makeSoundEventAccessor112(rKey); + var eventAccessorWrapped = ModAPI.util.wrap(eventAccessor); + soundPool.forEach(sound => { + eventAccessorWrapped.accessorList.add(sound); + }); + AsyncSink.Audio.Objects.push([rKey, eventAccessor]); + registry.put(rKey, eventAccessor); + values.map(x=>"resourcepacks/AsyncSinkLib/assets/minecraft/" + x.path + ".mcmeta").forEach(x=>AsyncSink.setFile(x, new ArrayBuffer(0))); + return soundPool; + } + } else { + const SoundPoolEntry = ModAPI.reflect.getClassByName("SoundPoolEntry").constructors.find(x => x.length === 4); + AsyncSink.Audio.register = function addSfx(key, category, values) { + if (!category) { + throw new Error("[AsyncSink] Invalid audio category provided: "+category); + } + var snd = ModAPI.mc.mcSoundHandler; + var registry = snd.sndRegistry.soundRegistry; + var rKey = ResourceLocation(ModAPI.util.str(key)); + var soundPool = values.map(se => { + var path = ResourceLocation(ModAPI.util.str(se.path)); + return SoundPoolEntry(path, se.pitch, se.volume, 1 * se.streaming); + }).map(spe => { + return makeSoundEventAccessor(spe, 1); // 1 = weight + }); + var compositeSound = makeSoundEventAccessorComposite(rKey, 1, 1, category); + var compositeSoundWrapped = ModAPI.util.wrap(compositeSound); + soundPool.forEach(sound => { + compositeSoundWrapped.soundPool.add(sound); + }); + AsyncSink.Audio.Objects.push([rKey, compositeSound]); + registry.put(rKey, compositeSound); + values.map(x=>"resourcepacks/AsyncSinkLib/assets/minecraft/" + x.path + ".mcmeta").forEach(x=>AsyncSink.setFile(x, new ArrayBuffer(0))); + return soundPool; } - var snd = ModAPI.mc.mcSoundHandler; - var registry = snd.sndRegistry.soundRegistry; - var rKey = ResourceLocation(ModAPI.util.str(key)); - var soundPool = values.map(se => { - var path = ResourceLocation(ModAPI.util.str(se.path)); - return SoundPoolEntry(path, se.pitch, se.volume, 1 * se.streaming); - }).map(spe => { - return makeSoundEventAccessor(spe, 1); // 1 = weight - }); - var compositeSound = makeSoundEventAccessorComposite(rKey, 1, 1, category); - var compositeSoundWrapped = ModAPI.util.wrap(compositeSound); - soundPool.forEach(sound => { - compositeSoundWrapped.soundPool.add(sound); - }); - AsyncSink.Audio.Objects.push([rKey, compositeSound]); - registry.put(rKey, compositeSound); - values.map(x=>"resourcepacks/AsyncSinkLib/assets/minecraft/" + x.path + ".mcmeta").forEach(x=>AsyncSink.setFile(x, new ArrayBuffer(0))); } })(); \ No newline at end of file From 46bd7111849f5418ea5ff0c857430ec2f636b852 Mon Sep 17 00:00:00 2001 From: Royan Xu <132798457+happylabdab2@users.noreply.github.com> Date: Fri, 25 Apr 2025 18:25:02 -0700 Subject: [PATCH 03/10] Update core.js Added magnify edgecase --- core/core.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/core.js b/core/core.js index 1e499d5..6b6f292 100644 --- a/core/core.js +++ b/core/core.js @@ -368,8 +368,12 @@ var main;(function(){` if (EFIConfig.doMinify) { _status("Shrinking file..."); await wait(50); - - patchedFile = await minify(patchedFile, parser, EFIConfig); + if (globalThis.process) { + let _minify = require("./minify").minify; + patchedFile = await _minify(patchedFile, parser, EFIConfig); + } else { + patchedFile = await minify(patchedFile, parser, EFIConfig); + } } @@ -436,4 +440,4 @@ if (globalThis.process) { patchClient: patchClient, conf: EFIConfig } -} \ No newline at end of file +} From 150776e6749beca061a611b5de76066e03054a1b Mon Sep 17 00:00:00 2001 From: radmanplays <95340057+radmanplays@users.noreply.github.com> Date: Sat, 26 Apr 2025 11:58:03 +0330 Subject: [PATCH 04/10] Update links --- index.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index efc0568..06664bd 100644 --- a/index.html +++ b/index.html @@ -113,7 +113,11 @@ https://github.com/Eaglercraft-Archive/unminified-eaglercraft-builds/releases/latest1.8: https://github.com/Eaglercraft-Archive/unminified-eaglercraft-builds/releases/latest + 1.12: https://github.com/Eaglercraft-Archive/unminified-eaglercraft-builds-1.12/releases/latest
From 8c0d5765e953e4cd31a0449293fbfbd6b7a66b96 Mon Sep 17 00:00:00 2001 From: Royan Xu <132798457+happylabdab2@users.noreply.github.com> Date: Sat, 26 Apr 2025 17:10:17 -0700 Subject: [PATCH 05/10] 1.12 method correction 1.8->1.12 method correction --- examplemods/AsyncSink.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/examplemods/AsyncSink.js b/examplemods/AsyncSink.js index 78b0b2e..b91154f 100644 --- a/examplemods/AsyncSink.js +++ b/examplemods/AsyncSink.js @@ -7,6 +7,13 @@ ModAPI.meta.credits("By ZXMushroom63"); const ResourceLocation = ModAPI.reflect.getClassByName("ResourceLocation").constructors.find(x => x.length === 1); //AsyncSink is a plugin to debug and override asynchronous methods in EaglercraftX async function runtimeComponent() { + let booleanResult; + //jl_Boolean_valueOf-> 1.12, nlevit_BooleanResult__new-> 1.8 + if (ModAPI.is_1_12) { + booleanResult = (b) => ModAPI.hooks.methods.jl_Boolean_valueOf(b * 1); + } else { + booleanResult = (b) => ModAPI.hooks.methods.nlevit_BooleanResult__new(b * 1); + } const booleanResult = (b) => ModAPI.hooks.methods.nlevit_BooleanResult__new(b * 1); const wrap = ModAPI.hooks.methods.otji_JSWrapper_wrap; const unwrap = ModAPI.hooks.methods.otji_JSWrapper_unwrap; @@ -401,4 +408,4 @@ ModAPI.meta.credits("By ZXMushroom63"); return soundPool; } } -})(); \ No newline at end of file +})(); From 99ee123897daa0337c6f9187309b8c1871709b4e Mon Sep 17 00:00:00 2001 From: Royan Xu <132798457+happylabdab2@users.noreply.github.com> Date: Sat, 26 Apr 2025 19:40:24 -0700 Subject: [PATCH 06/10] Update AsyncSink.js fix for the fix --- examplemods/AsyncSink.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examplemods/AsyncSink.js b/examplemods/AsyncSink.js index b91154f..1637176 100644 --- a/examplemods/AsyncSink.js +++ b/examplemods/AsyncSink.js @@ -8,9 +8,8 @@ ModAPI.meta.credits("By ZXMushroom63"); //AsyncSink is a plugin to debug and override asynchronous methods in EaglercraftX async function runtimeComponent() { let booleanResult; - //jl_Boolean_valueOf-> 1.12, nlevit_BooleanResult__new-> 1.8 if (ModAPI.is_1_12) { - booleanResult = (b) => ModAPI.hooks.methods.jl_Boolean_valueOf(b * 1); + booleanResult = (b) = ModAPI.reflect.getClassById("net.lax1dude.eaglercraft.internal.teavm.BooleanResult").constructors[0](b*1); } else { booleanResult = (b) => ModAPI.hooks.methods.nlevit_BooleanResult__new(b * 1); } From cdf2800977b408f37b607ff21142cf0a8fb8a2e7 Mon Sep 17 00:00:00 2001 From: Royan Xu <132798457+happylabdab2@users.noreply.github.com> Date: Sat, 26 Apr 2025 19:42:38 -0700 Subject: [PATCH 07/10] Update AsyncSink.js fixed fixed fix --- examplemods/AsyncSink.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examplemods/AsyncSink.js b/examplemods/AsyncSink.js index 1637176..fe7153d 100644 --- a/examplemods/AsyncSink.js +++ b/examplemods/AsyncSink.js @@ -8,12 +8,13 @@ ModAPI.meta.credits("By ZXMushroom63"); //AsyncSink is a plugin to debug and override asynchronous methods in EaglercraftX async function runtimeComponent() { let booleanResult; + if (ModAPI.is_1_12) { - booleanResult = (b) = ModAPI.reflect.getClassById("net.lax1dude.eaglercraft.internal.teavm.BooleanResult").constructors[0](b*1); + booleanResult = (b) => ModAPI.reflect.getClassById("net.lax1dude.eaglercraft.internal.teavm.BooleanResult").constructors[0](b*1); } else { booleanResult = (b) => ModAPI.hooks.methods.nlevit_BooleanResult__new(b * 1); } - const booleanResult = (b) => ModAPI.hooks.methods.nlevit_BooleanResult__new(b * 1); + const wrap = ModAPI.hooks.methods.otji_JSWrapper_wrap; const unwrap = ModAPI.hooks.methods.otji_JSWrapper_unwrap; function getAsyncHandlerName(name) { From cb0eb182d99e4c7525e57dfdf800a245780b28b7 Mon Sep 17 00:00:00 2001 From: ZXMushroom63 <116805577+ZXMushroom63@users.noreply.github.com> Date: Sun, 27 Apr 2025 14:12:35 +0800 Subject: [PATCH 08/10] Cache booleanresult in asyncsink 1.12 --- examplemods/AsyncSink.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examplemods/AsyncSink.js b/examplemods/AsyncSink.js index fe7153d..f5c1b08 100644 --- a/examplemods/AsyncSink.js +++ b/examplemods/AsyncSink.js @@ -10,7 +10,8 @@ ModAPI.meta.credits("By ZXMushroom63"); let booleanResult; if (ModAPI.is_1_12) { - booleanResult = (b) => ModAPI.reflect.getClassById("net.lax1dude.eaglercraft.internal.teavm.BooleanResult").constructors[0](b*1); + const _boolRes = ModAPI.reflect.getClassById("net.lax1dude.eaglercraft.internal.teavm.BooleanResult").constructors[0]; + booleanResult = (b) => _boolRes(b*1); } else { booleanResult = (b) => ModAPI.hooks.methods.nlevit_BooleanResult__new(b * 1); } From 38a4594f6d73e6d20a3e457662730fd8af3dbc63 Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Sun, 27 Apr 2025 18:48:44 +0800 Subject: [PATCH 09/10] decrease gui z-index --- core/modgui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/modgui.js b/core/modgui.js index 87d0853..7dbbec7 100644 --- a/core/modgui.js +++ b/core/modgui.js @@ -105,7 +105,7 @@ const modapi_guikit = "(" + (() => { height: 100vh; width: 100vw; position: fixed; - z-index: 9999999999; + z-index: 127; top: 0; left: 0; font-family: sans-serif; From a5534d87cdd7b1fb268f76d6f820e72d87619680 Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Sun, 27 Apr 2025 18:49:15 +0800 Subject: [PATCH 10/10] bump ver --- core/core.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/core.js b/core/core.js index 6b6f292..a7d30bc 100644 --- a/core/core.js +++ b/core/core.js @@ -14,7 +14,7 @@ var modapi_preinit = `globalThis.ModAPI ||= {}; `; var freezeCallstack = `if(ModAPI.hooks.freezeCallstack){return false};`; const EFIConfig = { - ModAPIVersion: "v2.7.6", //also change in package.json + ModAPIVersion: "v2.7.7", //also change in package.json doEaglerforge: true, verbose: false, doServerExtras: false, diff --git a/package.json b/package.json index 802150e..1c7c431 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eaglerforgeinjector", - "version": "2.7.6", + "version": "2.7.7", "description": "Advanced modding API injector for unminified, unobfuscated, unsigned eaglercraft builds.", "main": "node.js", "directories": {