1
0
Fork 0

Fix crash when attempting to create grass path with efficiency shovel

This commit is contained in:
Lizzy Fleckenstein 2021-01-17 12:39:11 +01:00
parent 4b61b3b4e5
commit bb0e5af6d0
1 changed files with 15 additions and 13 deletions

View File

@ -172,18 +172,20 @@ minetest.register_tool("mcl_tools:pick_diamond", {
_repair_material = "mcl_core:diamond", _repair_material = "mcl_core:diamond",
}) })
local get_shovel_dig_group = function(itemstring) local get_shovel_dig_group = function(itemstack)
local string_start = itemstring:sub(1, 21) local itemstring = itemstack:get_name()
if string_start == "mcl_tools:shovel_wood" then local efficiency_level = mcl_enchanting.get_enchantment(itemstack, "efficiency")
return "shovely_dig_wood" local postfix = efficiency_level > 0 and "_efficiency_" .. efficiency_level or ""
elseif string_start == "mcl_tools:shovel_ston" then if itemstring:find("mcl_tools:shovel_wood") == 1 then
return "shovely_dig_stone" return "shovely_dig_wood" .. postfix
elseif string_start == "mcl_tools:shovel_iron" then elseif itemstring:find("mcl_tools:shovel_stone") == 1 then
return "shovely_dig_iron" return "shovely_dig_stone" .. postfix
elseif string_start == "mcl_tools:shovel_gold" then elseif itemstring:find("mcl_tools:shovel_iron") == 1 then
return "shovely_dig_gold" return "shovely_dig_iron" .. postfix
elseif string_start == "mcl_tools:shovel_diam" then elseif itemstring:find("mcl_tools:shovel_gold") == 1 then
return "shovely_dig_diamond" return "shovely_dig_gold" .. postfix
elseif itemstring:find("mcl_tools:shovel_diamond") == 1 then
return "shovely_dig_diamond" .. postfix
else else
-- Fallback -- Fallback
return "shovely_dig_wood" return "shovely_dig_wood"
@ -217,7 +219,7 @@ local make_grass_path = function(itemstack, placer, pointed_thing)
-- Add wear, as if digging a level 0 shovely node -- Add wear, as if digging a level 0 shovely node
local toolname = itemstack:get_name() local toolname = itemstack:get_name()
local def = minetest.registered_items[toolname] local def = minetest.registered_items[toolname]
local group = get_shovel_dig_group(toolname) local group = get_shovel_dig_group(itemstack)
local toolcaps = itemstack:get_tool_capabilities() local toolcaps = itemstack:get_tool_capabilities()
local base_uses = toolcaps.groupcaps[group].uses local base_uses = toolcaps.groupcaps[group].uses
local maxlevel = toolcaps.groupcaps[group].maxlevel local maxlevel = toolcaps.groupcaps[group].maxlevel