mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-23 06:01:38 -09:00
add enchantment keygen
This commit is contained in:
parent
e3c7d474c5
commit
3979d7e0ce
@ -36,7 +36,7 @@ const modapi_postinit = "(" + (() => {
|
|||||||
}
|
}
|
||||||
function getCreditsString() {
|
function getCreditsString() {
|
||||||
return Object.entries(credits).map((entry) => {
|
return Object.entries(credits).map((entry) => {
|
||||||
return " "+entry[0] + LF + " " + (new Array(entry[0].length)).fill("~").join("") + entry[1].join("") + LF + LF + LF;
|
return " " + entry[0] + LF + " " + (new Array(entry[0].length)).fill("~").join("") + entry[1].join("") + LF + LF + LF;
|
||||||
}).join("");
|
}).join("");
|
||||||
}
|
}
|
||||||
ModAPI.array = {};
|
ModAPI.array = {};
|
||||||
@ -571,6 +571,24 @@ const modapi_postinit = "(" + (() => {
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (prop === "getCorrective") {
|
||||||
|
return function () {
|
||||||
|
return new Proxy(target, patchProxyConfToCorrective(TeaVMArray_To_Recursive_BaseData_ProxyConf));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (prop === "isCorrective") {
|
||||||
|
return function () {
|
||||||
|
return corrective;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (prop === "reload") {
|
||||||
|
return function () {
|
||||||
|
if (reloadDeprecationWarnings < 10) {
|
||||||
|
console.warn("ModAPI/PluginAPI reload() is obsolete, please stop using it in code.")
|
||||||
|
reloadDeprecationWarnings++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
var outputValue = Reflect.get(target, prop, receiver);
|
var outputValue = Reflect.get(target, prop, receiver);
|
||||||
var wrapped = ModAPI.util.wrap(outputValue, target, corrective, true);
|
var wrapped = ModAPI.util.wrap(outputValue, target, corrective, true);
|
||||||
if (wrapped) {
|
if (wrapped) {
|
||||||
@ -1196,8 +1214,10 @@ const modapi_postinit = "(" + (() => {
|
|||||||
var NonNullList = ModAPI.reflect.getClassById("net.minecraft.util.NonNullList").class;
|
var NonNullList = ModAPI.reflect.getClassById("net.minecraft.util.NonNullList").class;
|
||||||
var ArrayAsList = ModAPI.reflect.getClassById("java.util.Arrays$ArrayAsList").class;
|
var ArrayAsList = ModAPI.reflect.getClassById("java.util.Arrays$ArrayAsList").class;
|
||||||
}
|
}
|
||||||
|
|
||||||
function qhash(txt, arr, interval) {
|
ModAPI.util.qhash = function qhash(txt, arr, interval) {
|
||||||
|
arr ||= [];
|
||||||
|
interval ||= 32767;
|
||||||
// var interval = 4095; //used to be 4095 - arr.length, but that increases incompatibility based on load order and other circumstances
|
// var interval = 4095; //used to be 4095 - arr.length, but that increases incompatibility based on load order and other circumstances
|
||||||
if (arr.length >= interval) {
|
if (arr.length >= interval) {
|
||||||
console.error("[ModAPI.keygen] Ran out of IDs while generating for " + txt);
|
console.error("[ModAPI.keygen] Ran out of IDs while generating for " + txt);
|
||||||
@ -1253,13 +1273,22 @@ const modapi_postinit = "(" + (() => {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
const SoundEvent = ModAPI.reflect.getClassByName("SoundEvent")
|
const SoundEvent = ModAPI.reflect.getClassByName("SoundEvent")
|
||||||
const values = ModAPI.util.wrap(SoundEvent.staticVariables.REGISTRY).getCorrective().underlyingIntegerMap.identityMap.elementData.filter(x=>!!x).map(y=>y.value.value);
|
const values = ModAPI.util.wrap(SoundEvent.staticVariables.REGISTRY).getCorrective().underlyingIntegerMap.identityMap.elementData.filter(x => !!x).map(y => y.value.value);
|
||||||
return qhash(soundId, values, 4095);
|
return qhash(soundId, values, 4095);
|
||||||
}
|
}
|
||||||
|
ModAPI.keygen.enchantment = function (enchantment) {
|
||||||
|
const Enchantment = ModAPI.reflect.getClassByName("Enchantment");
|
||||||
|
if (ModAPI.is_1_12) {
|
||||||
|
const values = ModAPI.util.wrap(Enchantment.staticVariables.REGISTRY).getCorrective().underlyingIntegerMap.identityMap.elementData.filter(x => !!x).map(y => y.value.value);
|
||||||
|
return qhash(enchantment, values, 4095);
|
||||||
|
}
|
||||||
|
const values = ModAPI.util.wrap(Enchantment.staticVariables.enchantmentsList).getCorrective().filter(x => !!x).map(y => y.effectId);
|
||||||
|
return qhash(enchantment, values, 4095);
|
||||||
|
}
|
||||||
}).toString() + ")();";
|
}).toString() + ")();";
|
||||||
|
|
||||||
if (globalThis.process) {
|
if (globalThis.process) {
|
||||||
module.exports = {
|
module.exports = {
|
||||||
modapi_postinit: modapi_postinit
|
modapi_postinit: modapi_postinit
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user