mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-23 06:01:38 -09:00
v2.7.9
This commit is contained in:
parent
92ccade9fe
commit
5c4d4a3803
@ -14,7 +14,7 @@ var modapi_preinit = `globalThis.ModAPI ||= {};
|
||||
`;
|
||||
var freezeCallstack = `if(ModAPI.hooks.freezeCallstack){return false};`;
|
||||
const EFIConfig = {
|
||||
ModAPIVersion: "v2.7.8", //also change in package.json
|
||||
ModAPIVersion: "v2.7.9", //also change in package.json
|
||||
doEaglerforge: true,
|
||||
verbose: false,
|
||||
doServerExtras: false,
|
||||
@ -128,6 +128,7 @@ async function processClasses(string, parser) {
|
||||
assets.modapi_modloader = modapi_modloader;
|
||||
assets.modapi_guikit = modapi_guikit;
|
||||
}
|
||||
_status("Running EaglerForgeInjector " + EFIConfig.ModAPIVersion);
|
||||
if (string.includes("__eaglerforgeinjector_installation_flag__")) {
|
||||
backgroundLog("Detected input containing EFI installation flag.", true);
|
||||
return alert("this file already has EaglerForge injected in it, you nonce.\nif you're trying to update, you need a vanilla file.")
|
||||
|
@ -246,7 +246,6 @@ const modapi_postinit = "(" + (() => {
|
||||
}
|
||||
|
||||
ModAPI.util.asClass = ModAPI.hooks._teavm.$rt_cls;
|
||||
|
||||
ModAPI.util.wrap = function (outputValue, target, corrective, disableFunctions) {
|
||||
target ||= {};
|
||||
corrective ||= false;
|
||||
@ -259,6 +258,16 @@ const modapi_postinit = "(" + (() => {
|
||||
}
|
||||
return new Proxy(outputValue.data, ModAPI.util.TeaVMArray_To_Recursive_BaseData_ProxyConf);
|
||||
}
|
||||
if (ModAPI.is_1_12 && outputValue && typeof outputValue === "object" && outputValue.constructor === NonNullList) { //1.12 NonNullList support
|
||||
const targetProperty = Object.values(outputValue)?.find(x => x && typeof x === "object" && x.constructor === ArrayAsList);
|
||||
if (targetProperty) {
|
||||
const arrayProp = Object.values(targetProperty).find(x => x && typeof x === "object" && Array.isArray(x.data) && typeof x.type === "function");
|
||||
if (corrective) {
|
||||
return new Proxy(arrayProp.data, CorrectiveArray);
|
||||
}
|
||||
return new Proxy(arrayProp.data, ModAPI.util.TeaVMArray_To_Recursive_BaseData_ProxyConf);
|
||||
}
|
||||
}
|
||||
if (outputValue && typeof outputValue === "object" && !Array.isArray(outputValue)) {
|
||||
if (corrective) {
|
||||
return new Proxy(outputValue, CorrectiveRecursive);
|
||||
@ -643,6 +652,7 @@ const modapi_postinit = "(" + (() => {
|
||||
get(target, prop, receiver) {
|
||||
var outProp = prop;
|
||||
var outputValue = Reflect.get(target, outProp, receiver);
|
||||
outputValue ||= Reflect.get(target, outProp.toUpperCase(), receiver); //1.12 made a lot of variables uppercase (idk why)
|
||||
if (outputValue && typeof outputValue === "object" && Array.isArray(outputValue.data) && typeof outputValue.type === "function") {
|
||||
return new Proxy(outputValue.data, TeaVMArray_To_Recursive_BaseData_ProxyConf);
|
||||
}
|
||||
@ -799,6 +809,9 @@ const modapi_postinit = "(" + (() => {
|
||||
|
||||
//Function used for running @Async / @Async-dependent TeaVM methods.
|
||||
ModAPI.promisify = function promisify(fn) {
|
||||
if (typeof fn !== "function") {
|
||||
console.error("[ModAPI.promisify] Input was not a function: ", fn);
|
||||
}
|
||||
return function promisifiedJavaMethod(...inArguments) {
|
||||
return new Promise((res, rej) => {
|
||||
Promise.resolve().then( //queue microtask
|
||||
@ -1173,6 +1186,12 @@ 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);
|
||||
|
||||
// 1.12 utility junk
|
||||
if (ModAPI.is_1_12) {
|
||||
var NonNullList = ModAPI.reflect.getClassById("net.minecraft.util.NonNullList").class;
|
||||
var ArrayAsList = ModAPI.reflect.getClassById("java.util.Arrays$ArrayAsList").class;
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -14,7 +14,7 @@
|
||||
} catch (error) {
|
||||
//swallow
|
||||
}
|
||||
ModAPI.meta.config(()=>{
|
||||
ModAPI.meta.config(() => {
|
||||
var conf = document.createElement("div");
|
||||
conf.innerHTML = `
|
||||
<h1>Vein Miner Settings <a href="javascript:void(0)" onclick="this.parentElement.parentElement.remove()" style="color:red">[X]</a></h1>
|
||||
@ -25,7 +25,7 @@
|
||||
<label>Veinmine Clay: </label><input type=checkbox ${VEINMINERCONF.doClay ? "checked" : ""} oninput="VEINMINERCONF.doClay = this.checked; this.parentElement.__save();"></input><br>
|
||||
`;
|
||||
conf.style = "position: fixed; background-color: white; color: black; width: 100vw; height: 100vh; z-index: 256;top:0;left:0;";
|
||||
conf.__save = ()=>localStorage.setItem("trc_mod::conf", JSON.stringify(VEINMINERCONF));
|
||||
conf.__save = () => localStorage.setItem("trc_mod::conf", JSON.stringify(VEINMINERCONF));
|
||||
document.body.appendChild(conf);
|
||||
});
|
||||
|
||||
@ -33,6 +33,8 @@
|
||||
|
||||
ModAPI.dedicatedServer.appendCode(function () {
|
||||
ModAPI.addEventListener("bootstrap", () => {
|
||||
const axes = [ModAPI.items.iron_axe, ModAPI.items.stone_axe, ModAPI.items.golden_axe, ModAPI.items.wooden_axe, ModAPI.items.diamond_axe].map(x => x.getRef());
|
||||
const logs = ["log", "log2"].map(x => ModAPI.blocks[x].getRef());
|
||||
const targettedBlockIds = [];
|
||||
if (VEINMINERCONF.doLogs) {
|
||||
targettedBlockIds.push("log", "log2");
|
||||
@ -110,21 +112,23 @@
|
||||
|
||||
valid_log_blocks.forEach(b => {
|
||||
const originalHarvest = b.$harvestBlock;
|
||||
b.$harvestBlock = function ($theWorld, $player, $blockpos, $blockstate, $tileentity) {
|
||||
if ($player.$isSneaking() && !ModAPI.util.isCritical()) {
|
||||
b.$harvestBlock = function ($theWorld, $player, $blockpos, $blockstate, $tileentity, ...args) {
|
||||
const blockState = ModAPI.util.wrap($blockstate);
|
||||
const player = ModAPI.util.wrap($player);
|
||||
console.log(blockState, player);
|
||||
if (player.isSneaking() && !ModAPI.util.isCritical() && !(logs.includes(blockState.block.getRef()) && !axes.includes(player.inventory.mainInventory[player.inventory.currentItem]?.getCorrective()?.item?.getRef()))) {
|
||||
ModAPI.promisify(async () => {
|
||||
var player = ModAPI.util.wrap($player);
|
||||
var world = ModAPI.util.wrap($theWorld);
|
||||
var harvestCall = ModAPI.promisify(player.theItemInWorldManager.tryHarvestBlock);
|
||||
|
||||
const blocks = await getBlockGraph(ModAPI.util.wrap($blockpos), ModAPI.promisify(world.getBlockState), b);
|
||||
var harvestCall = ModAPI.promisify(ModAPI.is_1_12 ? player.interactionManager.tryHarvestBlock : player.theItemInWorldManager.tryHarvestBlock);
|
||||
|
||||
const blocks = await getBlockGraph(ModAPI.util.wrap($blockpos), ModAPI.promisify(world.getBlockState), b);
|
||||
console.log(blocks);
|
||||
for (let i = 0; i < blocks.length; i++) {
|
||||
await harvestCall(blocks[i].getRef());
|
||||
}
|
||||
})();
|
||||
}
|
||||
originalHarvest.apply(this, [$theWorld, $player, $blockpos, $blockstate, $tileentity]);
|
||||
originalHarvest.apply(this, [$theWorld, $player, $blockpos, $blockstate, $tileentity, ...args]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "eaglerforgeinjector",
|
||||
"version": "2.7.8",
|
||||
"version": "2.7.9",
|
||||
"description": "Advanced modding API injector for unminified, unobfuscated, unsigned eaglercraft builds.",
|
||||
"main": "node.js",
|
||||
"directories": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user