mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-26 04:21:07 +01:00
Fix crash when cannot get wear for tool
This commit is contained in:
parent
b72dbf17a6
commit
6c8113dec8
2 changed files with 14 additions and 3 deletions
|
@ -300,6 +300,10 @@ end
|
|||
-- loading order.
|
||||
function mcl_autogroup.get_wear(toolname, diggroup)
|
||||
local tdef = minetest.registered_tools[toolname]
|
||||
if not tdef then
|
||||
minetest.log("warning", "Adding wear for tool: " .. tostring(toolname) .. " failed with diggroup: " .. tostring(diggroup))
|
||||
return nil
|
||||
end
|
||||
local uses = tdef._mcl_diggroups[diggroup].uses
|
||||
return math.ceil(65535 / uses)
|
||||
end
|
||||
|
|
|
@ -183,8 +183,10 @@ local make_grass_path = function(itemstack, placer, pointed_thing)
|
|||
-- Add wear (as if digging a shovely node)
|
||||
local toolname = itemstack:get_name()
|
||||
local wear = mcl_autogroup.get_wear(toolname, "shovely")
|
||||
if wear then
|
||||
itemstack:add_wear(wear)
|
||||
end
|
||||
end
|
||||
minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = above}, true)
|
||||
minetest.swap_node(pointed_thing.under, {name="mcl_core:grass_path"})
|
||||
end
|
||||
|
@ -212,8 +214,11 @@ if minetest.get_modpath("mcl_farming") then
|
|||
-- Add wear (as if digging a shearsy node)
|
||||
local toolname = itemstack:get_name()
|
||||
local wear = mcl_autogroup.get_wear(toolname, "shearsy")
|
||||
if wear then
|
||||
itemstack:add_wear(wear)
|
||||
end
|
||||
|
||||
end
|
||||
minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = pointed_thing.above}, true)
|
||||
local dir = vector.subtract(pointed_thing.under, pointed_thing.above)
|
||||
local param2 = minetest.dir_to_facedir(dir)
|
||||
|
@ -379,9 +384,11 @@ local function make_stripped_trunk(itemstack, placer, pointed_thing)
|
|||
-- Add wear (as if digging a axey node)
|
||||
local toolname = itemstack:get_name()
|
||||
local wear = mcl_autogroup.get_wear(toolname, "axey")
|
||||
if wear then
|
||||
itemstack:add_wear(wear)
|
||||
end
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue