From cb5340920b7dd772fc63425f104cc41fb3014664 Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Tue, 6 May 2025 19:11:41 +0800 Subject: [PATCH] fix enchantments on 1.12 --- core/postinit.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/postinit.js b/core/postinit.js index bee8371..38e1fea 100644 --- a/core/postinit.js +++ b/core/postinit.js @@ -1104,10 +1104,14 @@ const modapi_postinit = "(" + (() => { } ModAPI.util.bootstrap = function () { - ModAPI.items = new Proxy(ModAPI.hooks._classMap[ModAPI.util.getCompiledName("net.minecraft.init.Items")].staticVariables, StaticProps_ProxyConf); - ModAPI.blocks = new Proxy(ModAPI.hooks._classMap[ModAPI.util.getCompiledName("net.minecraft.init.Blocks")].staticVariables, StaticProps_ProxyConf); - ModAPI.materials = new Proxy(ModAPI.hooks._classMap[ModAPI.util.getCompiledName("net.minecraft.block.material.Material")].staticVariables, StaticProps_ProxyConf); - ModAPI.enchantments = new Proxy(ModAPI.hooks._classMap[ModAPI.util.getCompiledName("net.minecraft.enchantment.Enchantment")].staticVariables, StaticProps_ProxyConf); //bugged on 1.12 due to more client optimisations. might need to change the optimisation intensity + ModAPI.items = new Proxy(ModAPI.reflect.getClassById("net.minecraft.init.Items").staticVariables, StaticProps_ProxyConf); + ModAPI.blocks = new Proxy(ModAPI.reflect.getClassById("net.minecraft.init.Blocks").staticVariables, StaticProps_ProxyConf); + ModAPI.materials = new Proxy(ModAPI.reflect.getClassById("net.minecraft.block.material.Material").staticVariables, StaticProps_ProxyConf); + if (ModAPI.is_1_12) { + ModAPI.enchantments = new Proxy(ModAPI.reflect.getClassById("net.minecraft.init.Enchantments").staticVariables, StaticProps_ProxyConf); + } else { + ModAPI.enchantments = new Proxy(ModAPI.reflect.getClassById("net.minecraft.enchantment.Enchantment").staticVariables, StaticProps_ProxyConf); + } } ModAPI.events.newEvent("bootstrap", "server");