From ec634c45bcfcb38d7827e401e425dfc9e9d96259 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 10 Jan 2023 14:19:15 +0000 Subject: [PATCH] Fixed enchanted book bug --- .../com/willfp/ecoenchants/mechanics/VillagerSupport.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/VillagerSupport.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/VillagerSupport.kt index 359d19d0..aac4c319 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/VillagerSupport.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/mechanics/VillagerSupport.kt @@ -94,8 +94,12 @@ class VillagerSupport( val meta = result.itemMeta if (meta is EnchantmentStorageMeta) { - for ((enchant, level) in enchants) { + // Remove existing enchants + for (enchant in meta.storedEnchants.keys) { meta.removeStoredEnchant(enchant) + } + + for ((enchant, level) in enchants) { meta.addStoredEnchant(enchant, level, true) } } else {