From 78a4732fdf386f19b20849183bbe30c7c2d5b351 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 28 Jun 2024 15:38:38 +0100 Subject: [PATCH] Fixed data driven enchantments not working --- .../proxy/v1_21/ModernEnchantmentRegisterer.kt | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/eco-core/core-nms/v1_21/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_21/ModernEnchantmentRegisterer.kt b/eco-core/core-nms/v1_21/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_21/ModernEnchantmentRegisterer.kt index 628390c0..914a6b12 100644 --- a/eco-core/core-nms/v1_21/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_21/ModernEnchantmentRegisterer.kt +++ b/eco-core/core-nms/v1_21/src/main/kotlin/com/willfp/ecoenchants/proxy/v1_21/ModernEnchantmentRegisterer.kt @@ -61,26 +61,16 @@ class ModernEnchantmentRegisterer : ModernEnchantmentRegistererProxy { .getDeclaredField("cache") .apply { isAccessible = true } - @Suppress("UNCHECKED_CAST") - private val vanillaEnchantments = Enchantments::class.java - .declaredFields - .asSequence() - .filter { it.type == ResourceKey::class.java } - .map { it.get(null) as ResourceKey } - .map { it.location() } - .map { CraftNamespacedKey.fromMinecraft(it) } - .toSet() - override fun replaceRegistry() { val newRegistryMTB = BiFunction { key, registry -> - val isVanilla = vanillaEnchantments.contains(key) val eco = EcoEnchants.getByID(key.key) + val registered = enchantmentRegistry.containsKey(CraftNamespacedKey.toMinecraft(key)) - if (isVanilla) { - ModifiedVanillaCraftEnchantment(key, registry) - } else if (eco != null) { + if (eco != null) { eco as Enchantment + } else if (registered) { + ModifiedVanillaCraftEnchantment(key, registry) } else { null }