Fix many workbench and enchanting table bugs from MT-Eurythmia
* fix crash https://github.com/Mynetest/Mynetest-server/issues/105 * detect that hammer is present and detect if that mese list are mese * backported https://github.com/MT-Eurythmia/xdecor/commit/59a65c60611ebe8ef3ced2e406968f049> * backported https://github.com/MT-Eurythmia/xdecor/commit/28a24a805be109eb8ab32b8633b1dfef5>
This commit is contained in:
parent
13a6891758
commit
901fb492c1
@ -112,6 +112,12 @@ function enchanting.fields(pos, _, fields, sender)
|
||||
local mod, name = tool:get_name():match("(.*):(.*)")
|
||||
local enchanted_tool = (mod or "") .. ":enchanted_" .. (name or "") .. "_" .. next(fields)
|
||||
|
||||
-- Mynetest: check that the "mese" list actually contains mese.
|
||||
if mese:get_name() ~= "default:mese_crystal" then
|
||||
inv:set_stack("mese", 1, nil)
|
||||
return
|
||||
end
|
||||
|
||||
if mese:get_count() >= mese_cost and reg_tools[enchanted_tool] then
|
||||
minetest.sound_play("xdecor_enchanting", {
|
||||
to_player = sender:get_player_name(),
|
||||
|
@ -134,6 +134,9 @@ local formspecs = {
|
||||
}
|
||||
|
||||
function workbench:set_formspec(meta, id)
|
||||
if not formspecs[id] then
|
||||
return
|
||||
end
|
||||
meta:set_string("formspec",
|
||||
"size[8,7;]list[current_player;main;0,3.25;8,4;]" ..
|
||||
formspecs[id] .. xbg .. default.get_hotbar_bg(0,3.25))
|
||||
@ -157,6 +160,16 @@ function workbench.fields(pos, _, fields)
|
||||
if fields.quit then return end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
if fields.back and meta then
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty("input") then
|
||||
inv:set_list("forms", {})
|
||||
else
|
||||
local input = inv:get_stack("input", 1)
|
||||
workbench:get_output(inv, input, input:get_name())
|
||||
end
|
||||
end
|
||||
|
||||
local id = fields.back and 1 or fields.craft and 2 or fields.storage and 3
|
||||
if not id then return end
|
||||
|
||||
@ -175,6 +188,13 @@ function workbench.timer(pos)
|
||||
local tool = inv:get_stack("tool", 1)
|
||||
local hammer = inv:get_stack("hammer", 1)
|
||||
|
||||
-- Mynetest: check that the item is a hammer. See https://github.com/Mynetest/Mynetest-server/issues/105
|
||||
if hammer:get_name() ~= "xdecor:hammer" then
|
||||
timer:stop()
|
||||
inv:set_stack("hammer", 1, nil)
|
||||
return
|
||||
end
|
||||
|
||||
if tool:is_empty() or hammer:is_empty() or tool:get_wear() == 0 then
|
||||
timer:stop()
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user