From 13a68917581429af24e0b3fd17ce450fbbf9aca8 Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Sun, 11 Jun 2023 19:56:30 -0400 Subject: [PATCH] xdecor - crash avoiting: Added further sanity check and update formspecs * update xdecir minenux up to 20230611 * backporting https://notabug.org/minenux/minetest-mod-xdecor/commit/3e0ca1304d454297739d6f8> * backporting https://github.com/0siribix/xdecor/commit/c7e756afc7d246817209c415c6e9a9dda533> * backporting https://github.com/0siribix/xdecor/commit/3823fce1e05a9472e7cf798c8346ba95ead1> * backporting https://notabug.org/minenux/minetest-mod-xdecor/commit/9f4002b749920a6aa906ce7> --- mods/README.md | 2 +- mods/xdecor/init.lua | 3 ++- mods/xdecor/src/enchanting.lua | 27 +++++++++++++++------------ mods/xdecor/src/workbench.lua | 12 ++++++++++++ 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/mods/README.md b/mods/README.md index 5e332db..e46f485 100644 --- a/mods/README.md +++ b/mods/README.md @@ -33,7 +33,7 @@ Most of those mods have mirror at http://git.mirror.org | walls | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/c7cb79422ba19c696966472942db6177c934838d | | | wool | https://codeberg.org/minenux/minetest-mod-wool | https://codeberg.org/minenux/minetest-mod-wool/commit/de642a08e80bfd7a4a1e5629e50458a609dbda3a | [wool/README.md](wool/README.md) | | xpanes | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/c7cb79422ba19c696966472942db6177c934838d | | -| xdecor | https://codeberg.org/minenux/minetest-game-xdecor | https://codeberg.org/minenux/minetest-game-xdecor/commit/f6d0f0b2a5c1d435217bb3409a76da9eb36fe889 | [xdecor/README.md](xdecor/README.md) | +| xdecor | https://codeberg.org/minenux/minetest-game-xdecor | https://codeberg.org/minenux/minetest-game-xdecor/commit/cd0c35b8c58153f7c353b5dbfac35e524fa0ea18 | [xdecor/README.md](xdecor/README.md) | The default mod provides sethome and player_api call ones, binoculars from v5 are just separate privilegies for zoom, butterflies and fireflies from v5 can be set diff --git a/mods/xdecor/init.lua b/mods/xdecor/init.lua index b2c333d..f41b9ce 100644 --- a/mods/xdecor/init.lua +++ b/mods/xdecor/init.lua @@ -2,6 +2,7 @@ xdecor = {} local modpath = minetest.get_modpath("xdecor") +local ar_api = minetest.get_modpath("3d_armor") -- Intllib local S @@ -27,7 +28,7 @@ else end xdecor.S = S -xdecor.reparaible_tools = {"pick", "axe", "shovel", "sword"} +xdecor.reparaible_tools = {"pick", "axe", "shovel", "hoe"} dofile(modpath .. "/handlers/animations.lua") dofile(modpath .. "/handlers/helpers.lua") diff --git a/mods/xdecor/src/enchanting.lua b/mods/xdecor/src/enchanting.lua index 5a76ce8..8323357 100644 --- a/mods/xdecor/src/enchanting.lua +++ b/mods/xdecor/src/enchanting.lua @@ -108,20 +108,23 @@ function enchanting.fields(pos, _, fields, sender) local tool = inv:get_stack("tool", 1) local mese = inv:get_stack("mese", 1) local orig_wear = tool:get_wear() - local mod, name = tool:get_name():match("(.*):(.*)") - local enchanted_tool = (mod or "") .. ":enchanted_" .. (name or "") .. "_" .. next(fields) + if tool and tool:get_name() and allowed_tools[tool:get_name()] then + local mod, name = tool:get_name():match("(.*):(.*)") + local enchanted_tool = (mod or "") .. ":enchanted_" .. (name or "") .. "_" .. next(fields) - if mese:get_count() >= mese_cost and reg_tools[enchanted_tool] then - minetest.sound_play("xdecor_enchanting", { - to_player = sender:get_player_name(), - gain = 0.8 - }) + if mese:get_count() >= mese_cost and reg_tools[enchanted_tool] then + minetest.sound_play("xdecor_enchanting", { + to_player = sender:get_player_name(), + gain = 0.8 + }) - tool:replace(enchanted_tool) - tool:add_wear(orig_wear) - mese:take_item(mese_cost) - inv:set_stack("mese", 1, mese) - inv:set_stack("tool", 1, tool) + tool:replace(enchanted_tool) + tool:add_wear(orig_wear) + mese:take_item(mese_cost) + inv:set_stack("mese", 1, mese) + inv:set_stack("tool", 1, tool) + end + enchanting.formspec(pos) end end diff --git a/mods/xdecor/src/workbench.lua b/mods/xdecor/src/workbench.lua index bc12333..3da902d 100644 --- a/mods/xdecor/src/workbench.lua +++ b/mods/xdecor/src/workbench.lua @@ -46,6 +46,18 @@ end function workbench:repairable(stack) if custom_repairable[stack] then return true end + if ar_api then + for _, t in ipairs({ + "armor_head", + "armor_torso", + "armor_legs", + "armor_feet", + "armor_shield", + }) do + if minetest.get_item_group(stack, t) then return true end + end + end + for _, t in ipairs(repairable_tools) do if stack:find(t) then return true