Fixed using enchantment table

This commit is contained in:
payton 2024-11-18 17:04:21 -07:00
parent 02cb0818a1
commit 1b688732fe
2 changed files with 10 additions and 5 deletions

View File

@ -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
local 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)

View File

@ -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