From e13f9b484976b7e6d094876daa5674211423ebfc Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Fri, 30 May 2025 16:57:07 +0800 Subject: [PATCH] blockSounds global --- core/postinit.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/postinit.js b/core/postinit.js index 2b03ce5..0a067c0 100644 --- a/core/postinit.js +++ b/core/postinit.js @@ -140,6 +140,9 @@ const modapi_postinit = "(" + (() => { } }); } + function easyStaticPropAlias(clsId, real, alias) { + easyAlias(ModAPI.reflect.getClassById(clsId).staticVariables, real, alias); + } ModAPI.meta.title = function (title) { if (!document.currentScript || document.currentScript.getAttribute("data-isMod") !== "true") { return console.log("[ModAPIMeta] Cannot set meta for non-mod script."); @@ -1130,6 +1133,11 @@ const modapi_postinit = "(" + (() => { } else { ModAPI.enchantments = new Proxy(ModAPI.reflect.getClassById("net.minecraft.enchantment.Enchantment").staticVariables, StaticProps_ProxyConf); } + + if (ModAPI.is_1_12) { + //1.12 specific globals + ModAPI.blockSounds = new Proxy(ModAPI.reflect.getClassById("net.minecraft.block.SoundType").staticVariables, StaticProps_ProxyConf); + } } ModAPI.events.newEvent("bootstrap", "server"); @@ -1211,8 +1219,10 @@ const modapi_postinit = "(" + (() => { // 1.12 utility junk if (ModAPI.is_1_12) { + var Block = ModAPI.reflect.getClassById("net.minecraft.block.Block").class; var NonNullList = ModAPI.reflect.getClassById("net.minecraft.util.NonNullList").class; var ArrayAsList = ModAPI.reflect.getClassById("java.util.Arrays$ArrayAsList").class; + easyStaticPropAlias("net.minecraft.block.Block", "REGISTRY", "blockRegistry"); } ModAPI.util.qhash = function qhash(txt, arr, interval) {