mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-23 06:01:38 -09:00
commit
557766347c
12
core/core.js
12
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,
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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() + ")();";
|
||||
|
@ -7,7 +7,15 @@ 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() {
|
||||
const booleanResult = (b) => ModAPI.hooks.methods.nlevit_BooleanResult__new(b * 1);
|
||||
let booleanResult;
|
||||
|
||||
if (ModAPI.is_1_12) {
|
||||
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);
|
||||
}
|
||||
|
||||
const wrap = ModAPI.hooks.methods.otji_JSWrapper_wrap;
|
||||
const unwrap = ModAPI.hooks.methods.otji_JSWrapper_unwrap;
|
||||
function getAsyncHandlerName(name) {
|
||||
@ -16,9 +24,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 +217,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 +250,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 +315,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 +326,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 +349,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);
|
||||
}
|
||||
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)));
|
||||
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;
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
@ -113,7 +113,11 @@
|
||||
</summary>
|
||||
<a
|
||||
href="https://github.com/Eaglercraft-Archive/unminified-eaglercraft-builds/releases/latest"
|
||||
>https://github.com/Eaglercraft-Archive/unminified-eaglercraft-builds/releases/latest</a
|
||||
>1.8: https://github.com/Eaglercraft-Archive/unminified-eaglercraft-builds/releases/latest</a
|
||||
>
|
||||
<a
|
||||
href="https://github.com/Eaglercraft-Archive/unminified-eaglercraft-builds-1.12/releases/latest"
|
||||
>1.12: https://github.com/Eaglercraft-Archive/unminified-eaglercraft-builds-1.12/releases/latest</a
|
||||
>
|
||||
</details>
|
||||
<details>
|
||||
|
@ -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": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user