From 6247c9eeb90bb5b58eea592c6c5ad1c9c20ddb63 Mon Sep 17 00:00:00 2001 From: payton Date: Tue, 3 Dec 2024 16:59:46 +0100 Subject: [PATCH] Fix enchanting table experience requirement in creative mode (#4705) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4705 Reviewed-by: Mikita Wiśniewski Co-authored-by: payton Co-committed-by: payton --- mods/ITEMS/mcl_enchanting/engine.lua | 13 +++++++++---- mods/ITEMS/mcl_enchanting/mod.conf | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/mods/ITEMS/mcl_enchanting/engine.lua b/mods/ITEMS/mcl_enchanting/engine.lua index dd01d5950..b0f5f2962 100644 --- a/mods/ITEMS/mcl_enchanting/engine.lua +++ b/mods/ITEMS/mcl_enchanting/engine.lua @@ -536,7 +536,10 @@ function mcl_enchanting.show_enchanting_formspec(player) for i, slot in ipairs(table_slots) do any_enchantment = any_enchantment or slot local enough_lapis = inv:contains_item("enchanting_lapis", ItemStack({ name = "mcl_core:lapis", count = i })) - local enough_levels = slot and slot.level_requirement <= player_levels + local enough_levels = true + if mcl_gamemode.get_gamemode(player) == "survival" then + enough_levels = slot and slot.level_requirement <= player_levels + end local can_enchant = (slot and enough_lapis and enough_levels) local ending = (can_enchant and "" or "_off") local hover_ending = (can_enchant and "_hovered" or "_off") @@ -606,10 +609,12 @@ function mcl_enchanting.handle_formspec_fields(player, formname, fields) return end local player_level = mcl_experience.get_level(player) - if player_level < slot.level_requirement then - return + if mcl_gamemode.get_gamemode(player) == "survival" then + if player_level < slot.level_requirement then + return + end + mcl_experience.set_level(player, player_level - button_pressed) end - mcl_experience.set_level(player, player_level - button_pressed) inv:remove_item("enchanting_lapis", cost) mcl_enchanting.set_enchanted_itemstring(itemstack) mcl_enchanting.set_enchantments(itemstack, slot.enchantments) diff --git a/mods/ITEMS/mcl_enchanting/mod.conf b/mods/ITEMS/mcl_enchanting/mod.conf index d163fcd55..d12b52e4f 100644 --- a/mods/ITEMS/mcl_enchanting/mod.conf +++ b/mods/ITEMS/mcl_enchanting/mod.conf @@ -1,5 +1,5 @@ name = mcl_enchanting description = Enchanting for MineClone2 -depends = tt, walkover, mcl_sounds, mcl_colors, mcl_experience, mcl_util +depends = tt, walkover, mcl_sounds, mcl_colors, mcl_experience, mcl_util, mcl_gamemode optional_depends = screwdriver author = Fleckenstein