update block and item keygen functions for 1.12

This commit is contained in:
ZXMushroom63 2025-05-30 17:24:03 +08:00
parent 734db357cf
commit 5ee3e7d97f

View File

@ -1224,6 +1224,7 @@ 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;
easyStaticPropAlias("net.minecraft.block.Block", "REGISTRY", "blockRegistry"); easyStaticPropAlias("net.minecraft.block.Block", "REGISTRY", "blockRegistry");
easyStaticPropAlias("net.minecraft.item.Item", "REGISTRY", "itemRegistry");
} }
ModAPI.util.qhash = function qhash(txt, arr, interval) { ModAPI.util.qhash = function qhash(txt, arr, interval) {
@ -1257,11 +1258,19 @@ const modapi_postinit = "(" + (() => {
return registryNamespaceMethod.apply(this, args); return registryNamespaceMethod.apply(this, args);
} }
ModAPI.keygen.item = function (item) { ModAPI.keygen.item = function (item) {
var values = [...ModAPI.reflect.getClassById("net.minecraft.item.Item").staticVariables.itemRegistry.$modapi_specmap.values()]; if (ModAPI.is_1_12) {
var values = ModAPI.util.wrap(ModAPI.reflect.getClassById("net.minecraft.item.Item").staticVariables.REGISTRY).getCorrective().underlyingIntegerMap.identityMap.elementData.filter(x => !!x).map(y => y.value.value);
} else {
var values = [...ModAPI.reflect.getClassById("net.minecraft.item.Item").staticVariables.itemRegistry.$modapi_specmap.values()];
}
return qhash(item, values, 4095); return qhash(item, values, 4095);
} }
ModAPI.keygen.block = function (block) { ModAPI.keygen.block = function (block) {
var values = [...ModAPI.reflect.getClassById("net.minecraft.block.Block").staticVariables.blockRegistry.$modapi_specmap.values()]; if (ModAPI.is_1_12) {
var values = ModAPI.util.wrap(ModAPI.reflect.getClassById("net.minecraft.block.Block").staticVariables.REGISTRY).getCorrective().underlyingIntegerMap.identityMap.elementData.filter(x => !!x).map(y => y.value.value);
} else {
var values = [...ModAPI.reflect.getClassById("net.minecraft.block.Block").staticVariables.blockRegistry.$modapi_specmap.values()];
}
return qhash(block, values, 4095); return qhash(block, values, 4095);
} }
ModAPI.keygen.entity = function (entity) { ModAPI.keygen.entity = function (entity) {