2021-03-09 21:43:25 +01:00
|
|
|
--[[
|
|
|
|
This mod implements a HACK to make 100% sure the digging times of all tools
|
|
|
|
match Minecraft's perfectly. The digging times system of Minetest is very
|
|
|
|
different, so this weird group trickery has to be used. In Minecraft, each
|
|
|
|
block has a hardness and the actual Minecraft digging time is determined by
|
|
|
|
this:
|
2017-02-26 19:38:40 +01:00
|
|
|
|
|
|
|
1) The block's hardness
|
2021-03-20 19:25:47 +01:00
|
|
|
2) The tool being used (the tool speed and its efficiency level)
|
2021-03-09 21:43:25 +01:00
|
|
|
3) Whether the tool is considered as "eligible" for the block
|
2017-02-26 19:38:40 +01:00
|
|
|
(e.g. only diamond pick eligible for obsidian)
|
2021-03-09 21:43:25 +01:00
|
|
|
|
|
|
|
See Minecraft Wiki <http://minecraft.gamepedia.com/Minecraft_Wiki> for more
|
|
|
|
information.
|
|
|
|
|
|
|
|
How the mod is used
|
|
|
|
===================
|
|
|
|
|
2024-05-02 06:04:41 +02:00
|
|
|
In VoxeLibre, all diggable nodes have the hardness set in the custom field
|
2021-03-16 16:10:57 +01:00
|
|
|
"_mcl_hardness" (0 by default). These values are used together with digging
|
|
|
|
groups by this mod to create the correct digging times for nodes. Digging
|
|
|
|
groups are registered using the following code:
|
2021-03-09 21:43:25 +01:00
|
|
|
|
2021-03-16 16:10:57 +01:00
|
|
|
mcl_autogroup.register_diggroup("shovely")
|
2021-03-15 21:55:59 +01:00
|
|
|
mcl_autogroup.register_diggroup("pickaxey", {
|
|
|
|
levels = { "wood", "gold", "stone", "iron", "diamond" }
|
|
|
|
})
|
2021-03-09 21:43:25 +01:00
|
|
|
|
2021-03-16 16:10:57 +01:00
|
|
|
The first line registers a simple digging group. The second line registers a
|
|
|
|
digging group with 5 different levels (in this case one for each material of a
|
|
|
|
pickaxes).
|
2021-03-09 21:43:25 +01:00
|
|
|
|
|
|
|
Nodes indicate that they belong to a particular digging group by being member of
|
|
|
|
the digging group in their node definition. "mcl_core:dirt" for example has
|
|
|
|
shovely=1 in its groups. If the digging group has multiple levels the value of
|
|
|
|
the group indicates which digging level the node requires.
|
2021-03-15 21:55:59 +01:00
|
|
|
"mcl_core:stone_with_gold" for example has pickaxey=4 because it requires a
|
2021-03-16 16:10:57 +01:00
|
|
|
pickaxe of level 4 be mined.
|
|
|
|
|
|
|
|
For tools to be able to dig nodes of digging groups they need to use the have
|
2021-03-16 20:36:38 +01:00
|
|
|
the custom field "_mcl_diggroups" function to get the groupcaps. The value of
|
|
|
|
this field is a table which defines which groups the tool can dig and how
|
|
|
|
efficiently.
|
2021-03-16 16:10:57 +01:00
|
|
|
|
2021-03-16 20:36:38 +01:00
|
|
|
_mcl_diggroups = {
|
2021-03-20 19:25:47 +01:00
|
|
|
handy = { speed = 1, level = 1, uses = 0 },
|
|
|
|
pickaxey = { speed = 1, level = 0, uses = 0 },
|
2021-03-16 16:10:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
The "uses" field indicate how many uses (0 for infinite) a tool has when used on
|
2021-03-20 19:25:47 +01:00
|
|
|
the specified digging group. The "speed" field is a multiplier to the dig speed
|
|
|
|
on that digging group.
|
2021-03-09 21:43:25 +01:00
|
|
|
|
2021-03-16 16:10:57 +01:00
|
|
|
The "level" field indicates which levels of the group the tool can harvest. A
|
|
|
|
level of 0 means that the tool cannot harvest blocks of that node. A level of 1
|
|
|
|
or above means that the tool can harvest nodes with that level or below. See
|
2021-03-16 20:36:38 +01:00
|
|
|
"mcl_tools/init.lua" for examples on how "_mcl_diggroups" is used in practice.
|
2021-03-09 21:43:25 +01:00
|
|
|
|
|
|
|
Information about the mod
|
|
|
|
=========================
|
|
|
|
|
2021-03-18 11:34:20 +01:00
|
|
|
The mod is split up into two parts, mcl_autogroup and _mcl_autogroup.
|
|
|
|
mcl_autogroup contains the API functions used to register custom digging groups.
|
|
|
|
_mcl_autogroup contains most of the code. The leading underscore in the name
|
|
|
|
"_mcl_autogroup" is used to force Minetest to load that part of the mod as late
|
|
|
|
as possible. Minetest loads mods in reverse alphabetical order.
|
2021-03-18 11:35:29 +01:00
|
|
|
|
2021-03-16 20:27:35 +01:00
|
|
|
This also means that it is very important that no mod adds _mcl_autogroup as a
|
2021-03-18 11:35:29 +01:00
|
|
|
dependency.
|
2021-03-09 21:43:25 +01:00
|
|
|
--]]
|
|
|
|
|
2021-03-20 19:32:04 +01:00
|
|
|
assert(minetest.get_modpath("mcl_autogroup"), "This mod requires the mod mcl_autogroup to function")
|
|
|
|
|
2021-03-09 21:43:25 +01:00
|
|
|
-- Returns a table containing the unique "_mcl_hardness" for nodes belonging to
|
2021-03-11 15:06:30 +01:00
|
|
|
-- each diggroup.
|
2021-03-09 21:43:25 +01:00
|
|
|
local function get_hardness_values_for_groups()
|
|
|
|
local maps = {}
|
|
|
|
local values = {}
|
2021-03-11 15:06:30 +01:00
|
|
|
for g, _ in pairs(mcl_autogroup.registered_diggroups) do
|
2021-03-09 21:43:25 +01:00
|
|
|
maps[g] = {}
|
|
|
|
values[g] = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
for _, ndef in pairs(minetest.registered_nodes) do
|
2021-03-11 15:06:30 +01:00
|
|
|
for g, _ in pairs(mcl_autogroup.registered_diggroups) do
|
2021-05-29 16:12:33 +02:00
|
|
|
if ndef.groups[g] then
|
2021-03-09 21:43:25 +01:00
|
|
|
maps[g][ndef._mcl_hardness or 0] = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for g, map in pairs(maps) do
|
|
|
|
for k, _ in pairs(map) do
|
|
|
|
table.insert(values[g], k)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-03-11 15:06:30 +01:00
|
|
|
for g, _ in pairs(mcl_autogroup.registered_diggroups) do
|
2021-03-09 21:43:25 +01:00
|
|
|
table.sort(values[g])
|
|
|
|
end
|
|
|
|
return values
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Returns a table containing a table indexed by "_mcl_hardness_value" to get
|
2021-03-11 15:06:30 +01:00
|
|
|
-- its index in the list of unique hardnesses for each diggroup.
|
2021-03-09 21:43:25 +01:00
|
|
|
local function get_hardness_lookup_for_groups(hardness_values)
|
2021-03-17 11:45:20 +01:00
|
|
|
local map = {}
|
2021-03-09 21:43:25 +01:00
|
|
|
for g, values in pairs(hardness_values) do
|
|
|
|
map[g] = {}
|
|
|
|
for k, v in pairs(values) do
|
|
|
|
map[g][v] = k
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return map
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Array of unique hardness values for each group which affects dig time.
|
|
|
|
local hardness_values = get_hardness_values_for_groups()
|
|
|
|
|
|
|
|
-- Map indexed by hardness values which return the index of that value in
|
|
|
|
-- hardness_value. Used for quick lookup.
|
|
|
|
local hardness_lookup = get_hardness_lookup_for_groups(hardness_values)
|
|
|
|
|
2021-05-25 01:26:26 +02:00
|
|
|
--[[local function compute_creativetimes(group)
|
2021-03-09 21:43:25 +01:00
|
|
|
local creativetimes = {}
|
|
|
|
|
|
|
|
for index, hardness in pairs(hardness_values[group]) do
|
|
|
|
table.insert(creativetimes, 0)
|
|
|
|
end
|
|
|
|
|
|
|
|
return creativetimes
|
2021-05-25 01:26:26 +02:00
|
|
|
end]]
|
2021-03-09 21:43:25 +01:00
|
|
|
|
2021-03-11 15:06:30 +01:00
|
|
|
-- Get the list of digging times for using a specific tool on a specific
|
|
|
|
-- diggroup.
|
2021-03-09 21:43:25 +01:00
|
|
|
--
|
|
|
|
-- Parameters:
|
|
|
|
-- group - the group which it is digging
|
|
|
|
-- can_harvest - if the tool can harvest the block
|
2021-03-20 19:25:47 +01:00
|
|
|
-- speed - dig speed multiplier for tool (default 1)
|
2021-03-16 16:10:57 +01:00
|
|
|
-- efficiency - efficiency level for the tool if applicable
|
2021-03-20 19:25:47 +01:00
|
|
|
local function get_digtimes(group, can_harvest, speed, efficiency)
|
|
|
|
local speed = speed or 1
|
2021-03-15 21:55:59 +01:00
|
|
|
if efficiency then
|
2021-03-20 19:25:47 +01:00
|
|
|
speed = speed + efficiency * efficiency + 1
|
2021-03-09 21:43:25 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
local digtimes = {}
|
|
|
|
|
|
|
|
for index, hardness in pairs(hardness_values[group]) do
|
2021-03-20 19:25:47 +01:00
|
|
|
local digtime = (hardness or 0) / speed
|
2021-03-09 21:43:25 +01:00
|
|
|
if can_harvest then
|
|
|
|
digtime = digtime * 1.5
|
|
|
|
else
|
|
|
|
digtime = digtime * 5
|
|
|
|
end
|
|
|
|
|
|
|
|
if digtime <= 0.05 then
|
|
|
|
digtime = 0
|
|
|
|
else
|
|
|
|
digtime = math.ceil(digtime * 20) / 20
|
2020-11-02 13:38:17 +01:00
|
|
|
end
|
2021-03-09 21:43:25 +01:00
|
|
|
table.insert(digtimes, digtime)
|
2017-02-26 18:44:48 +01:00
|
|
|
end
|
2021-03-09 21:43:25 +01:00
|
|
|
|
|
|
|
return digtimes
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Get one groupcap field for using a specific tool on a specific group.
|
|
|
|
local function get_groupcap(group, can_harvest, multiplier, efficiency, uses)
|
|
|
|
return {
|
|
|
|
times = get_digtimes(group, can_harvest, multiplier, efficiency),
|
|
|
|
uses = uses,
|
|
|
|
maxlevel = 0,
|
|
|
|
}
|
2017-02-26 18:44:48 +01:00
|
|
|
end
|
2021-03-09 21:43:25 +01:00
|
|
|
|
2021-03-16 20:36:38 +01:00
|
|
|
-- Add the groupcaps from a field in "_mcl_diggroups" to the groupcaps of a
|
|
|
|
-- tool.
|
2021-03-16 20:19:19 +01:00
|
|
|
local function add_groupcaps(toolname, groupcaps, groupcaps_def, efficiency)
|
2021-03-23 12:02:00 +01:00
|
|
|
if not groupcaps_def then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2021-03-09 21:43:25 +01:00
|
|
|
for g, capsdef in pairs(groupcaps_def) do
|
2021-03-20 19:25:47 +01:00
|
|
|
local mult = capsdef.speed or 1
|
2021-03-11 15:11:11 +01:00
|
|
|
local uses = capsdef.uses
|
2021-03-11 15:06:30 +01:00
|
|
|
local def = mcl_autogroup.registered_diggroups[g]
|
2021-03-15 21:55:59 +01:00
|
|
|
local max_level = def.levels and #def.levels or 1
|
2021-03-16 20:19:19 +01:00
|
|
|
|
|
|
|
assert(capsdef.level, toolname .. ' is missing level for ' .. g)
|
|
|
|
local level = math.min(capsdef.level, max_level)
|
2021-03-09 21:43:25 +01:00
|
|
|
|
2021-03-15 21:55:59 +01:00
|
|
|
if def.levels then
|
|
|
|
groupcaps[g .. "_dig_default"] = get_groupcap(g, false, mult, efficiency, uses)
|
|
|
|
if level > 0 then
|
|
|
|
groupcaps[g .. "_dig_" .. def.levels[level]] = get_groupcap(g, true, mult, efficiency, uses)
|
|
|
|
end
|
2021-03-09 21:43:25 +01:00
|
|
|
else
|
2021-03-15 21:55:59 +01:00
|
|
|
groupcaps[g .. "_dig"] = get_groupcap(g, level > 0, mult, efficiency, uses)
|
2021-03-09 21:43:25 +01:00
|
|
|
end
|
2020-11-02 13:38:17 +01:00
|
|
|
end
|
2017-02-26 18:44:48 +01:00
|
|
|
end
|
|
|
|
|
2021-03-15 21:55:59 +01:00
|
|
|
-- Checks if the given node would drop its useful drop if dug by a given tool.
|
|
|
|
-- Returns true if it will yield its useful drop, false otherwise.
|
2023-01-11 19:31:56 +01:00
|
|
|
function mcl_autogroup.can_harvest(nodename, toolname, player)
|
2021-03-09 21:43:25 +01:00
|
|
|
local ndef = minetest.registered_nodes[nodename]
|
|
|
|
|
2021-06-15 01:13:24 +02:00
|
|
|
if not ndef then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2021-03-15 21:55:59 +01:00
|
|
|
if minetest.get_item_group(nodename, "dig_immediate") >= 2 then
|
2021-03-09 21:43:25 +01:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2023-06-04 02:20:50 +02:00
|
|
|
if minetest.get_item_group(nodename, "dig_immediate_piston") >= 1 then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2021-03-15 21:55:59 +01:00
|
|
|
-- Check if it can be dug by tool
|
|
|
|
local tdef = minetest.registered_tools[toolname]
|
2021-03-20 11:02:16 +01:00
|
|
|
if tdef and tdef._mcl_diggroups then
|
2021-03-16 20:36:38 +01:00
|
|
|
for g, gdef in pairs(tdef._mcl_diggroups) do
|
2021-03-15 21:55:59 +01:00
|
|
|
if ndef.groups[g] then
|
2021-03-16 20:19:19 +01:00
|
|
|
if ndef.groups[g] <= gdef.level then
|
2021-03-15 21:55:59 +01:00
|
|
|
return true
|
|
|
|
end
|
2021-03-09 21:43:25 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-03-15 21:55:59 +01:00
|
|
|
|
|
|
|
-- Check if it can be dug by hand
|
2023-01-11 19:31:56 +01:00
|
|
|
if not player or not player:is_player() then return false end
|
|
|
|
local name = player:get_inventory():get_stack("hand", 1):get_name()
|
|
|
|
local tdef = minetest.registered_items[name]
|
2021-03-15 21:55:59 +01:00
|
|
|
if tdef then
|
2021-03-16 20:36:38 +01:00
|
|
|
for g, gdef in pairs(tdef._mcl_diggroups) do
|
2021-03-15 21:55:59 +01:00
|
|
|
if ndef.groups[g] then
|
2021-03-16 20:19:19 +01:00
|
|
|
if ndef.groups[g] <= gdef.level then
|
2021-03-15 21:55:59 +01:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-03-09 21:43:25 +01:00
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2021-03-11 21:52:00 +01:00
|
|
|
-- Get one groupcap field for using a specific tool on a specific group.
|
2021-05-25 01:26:26 +02:00
|
|
|
--[[local function get_groupcap(group, can_harvest, multiplier, efficiency, uses)
|
2021-03-11 21:52:00 +01:00
|
|
|
return {
|
|
|
|
times = get_digtimes(group, can_harvest, multiplier, efficiency),
|
|
|
|
uses = uses,
|
|
|
|
maxlevel = 0,
|
|
|
|
}
|
2021-05-25 01:26:26 +02:00
|
|
|
end]]
|
2021-03-11 21:52:00 +01:00
|
|
|
|
2021-03-17 16:59:26 +01:00
|
|
|
-- Returns the tool_capabilities from a tool definition or a default set of
|
|
|
|
-- tool_capabilities
|
|
|
|
local function get_tool_capabilities(tdef)
|
|
|
|
if tdef.tool_capabilities then
|
|
|
|
return tdef.tool_capabilities
|
|
|
|
end
|
2021-03-17 17:09:19 +01:00
|
|
|
|
|
|
|
-- If the damage group and punch interval from hand is not included,
|
|
|
|
-- then the user will not be able to attack with the tool.
|
2023-01-11 19:31:56 +01:00
|
|
|
local hand_toolcaps = mcl_meshhand.survival_hand_tool_caps
|
2021-03-17 17:09:19 +01:00
|
|
|
return {
|
|
|
|
full_punch_interval = hand_toolcaps.full_punch_interval,
|
|
|
|
damage_groups = hand_toolcaps.damage_groups
|
|
|
|
}
|
2021-03-17 16:59:26 +01:00
|
|
|
end
|
|
|
|
|
2021-03-11 21:52:00 +01:00
|
|
|
-- Get the groupcaps for a tool. This function returns "groupcaps" table of
|
|
|
|
-- digging which should be put in the "tool_capabilities" of the tool definition
|
|
|
|
-- or in the metadata of an enchanted tool.
|
|
|
|
--
|
|
|
|
-- Parameters:
|
2021-03-18 11:35:29 +01:00
|
|
|
-- toolname - Name of the tool being enchanted (like "mcl_tools:diamond_pickaxe")
|
2021-03-11 21:52:00 +01:00
|
|
|
-- efficiency - The efficiency level the tool is enchanted with (default 0)
|
|
|
|
--
|
2021-05-25 01:26:26 +02:00
|
|
|
-- NOTE:
|
2021-03-18 11:35:29 +01:00
|
|
|
-- This function can only be called after mod initialization. Otherwise a mod
|
|
|
|
-- would have to add _mcl_autogroup as a dependency which would break the mod
|
|
|
|
-- loading order.
|
|
|
|
function mcl_autogroup.get_groupcaps(toolname, efficiency)
|
2023-01-11 19:31:56 +01:00
|
|
|
local tdef = minetest.registered_items[toolname]
|
2021-03-17 16:59:26 +01:00
|
|
|
local groupcaps = table.copy(get_tool_capabilities(tdef).groupcaps or {})
|
2021-03-16 20:36:38 +01:00
|
|
|
add_groupcaps(toolname, groupcaps, tdef._mcl_diggroups, efficiency)
|
2021-03-11 21:52:00 +01:00
|
|
|
return groupcaps
|
|
|
|
end
|
|
|
|
|
2021-03-18 11:35:29 +01:00
|
|
|
-- Get the wear from using a tool on a digging group.
|
|
|
|
--
|
|
|
|
-- Parameters
|
|
|
|
-- toolname - Name of the tool used
|
|
|
|
-- diggroup - The name of the diggroup the tool is used on
|
|
|
|
--
|
2021-05-25 01:26:26 +02:00
|
|
|
-- NOTE:
|
2021-03-18 11:35:29 +01:00
|
|
|
-- This function can only be called after mod initialization. Otherwise a mod
|
|
|
|
-- would have to add _mcl_autogroup as a dependency which would break the mod
|
|
|
|
-- loading order.
|
|
|
|
function mcl_autogroup.get_wear(toolname, diggroup)
|
|
|
|
local tdef = minetest.registered_tools[toolname]
|
2023-03-25 01:34:38 +01:00
|
|
|
if not tdef then
|
|
|
|
minetest.log("warning", "Adding wear for tool: " .. tostring(toolname) .. " failed with diggroup: " .. tostring(diggroup))
|
|
|
|
return nil
|
|
|
|
end
|
2021-03-16 20:36:38 +01:00
|
|
|
local uses = tdef._mcl_diggroups[diggroup].uses
|
2021-03-18 11:35:29 +01:00
|
|
|
return math.ceil(65535 / uses)
|
|
|
|
end
|
|
|
|
|
2021-05-25 12:52:25 +02:00
|
|
|
local function overwrite()
|
2017-02-10 06:01:20 +01:00
|
|
|
for nname, ndef in pairs(minetest.registered_nodes) do
|
2017-02-25 16:19:24 +01:00
|
|
|
local newgroups = table.copy(ndef.groups)
|
2017-03-30 03:07:04 +02:00
|
|
|
if (nname ~= "ignore" and ndef.diggable) then
|
2021-03-09 21:43:25 +01:00
|
|
|
-- Automatically assign the "solid" group for solid nodes
|
2017-02-25 16:19:24 +01:00
|
|
|
if (ndef.walkable == nil or ndef.walkable == true)
|
|
|
|
and (ndef.collision_box == nil or ndef.collision_box.type == "regular")
|
|
|
|
and (ndef.node_box == nil or ndef.node_box.type == "regular")
|
|
|
|
and (ndef.groups.not_solid == 0 or ndef.groups.not_solid == nil) then
|
|
|
|
newgroups.solid = 1
|
2017-03-10 20:01:45 +01:00
|
|
|
end
|
2021-03-09 21:43:25 +01:00
|
|
|
-- Automatically assign the "opaque" group for opaque nodes
|
2018-01-28 19:25:05 +01:00
|
|
|
if (not (ndef.paramtype == "light" or ndef.sunlight_propagates)) and
|
|
|
|
(ndef.groups.not_opaque == 0 or ndef.groups.not_opaque == nil) then
|
2017-03-10 20:01:45 +01:00
|
|
|
newgroups.opaque = 1
|
2017-02-27 00:29:56 +01:00
|
|
|
end
|
|
|
|
|
2021-05-25 01:26:26 +02:00
|
|
|
--local creative_breakable = false
|
2021-03-17 17:50:52 +01:00
|
|
|
|
2021-03-11 14:49:09 +01:00
|
|
|
-- Assign groups used for digging this node depending on
|
|
|
|
-- the registered digging groups
|
2021-03-11 15:06:30 +01:00
|
|
|
for g, gdef in pairs(mcl_autogroup.registered_diggroups) do
|
2021-05-25 01:26:26 +02:00
|
|
|
--creative_breakable = true
|
2021-03-11 21:07:51 +01:00
|
|
|
local index = hardness_lookup[g][ndef._mcl_hardness or 0]
|
2021-03-09 21:43:25 +01:00
|
|
|
if ndef.groups[g] then
|
|
|
|
if gdef.levels then
|
2021-03-15 21:55:59 +01:00
|
|
|
newgroups[g .. "_dig_default"] = index
|
|
|
|
|
|
|
|
for i = ndef.groups[g], #gdef.levels do
|
|
|
|
newgroups[g .. "_dig_" .. gdef.levels[i]] = index
|
2020-11-02 13:38:17 +01:00
|
|
|
end
|
2021-03-09 21:43:25 +01:00
|
|
|
else
|
|
|
|
newgroups[g .. "_dig"] = index
|
2017-02-26 20:50:02 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-02-25 16:19:24 +01:00
|
|
|
|
2021-03-17 17:50:52 +01:00
|
|
|
-- Automatically assign the node to the
|
|
|
|
-- creative_breakable group if it belongs to any digging
|
|
|
|
-- group.
|
|
|
|
newgroups["creative_breakable"] = 1
|
|
|
|
|
2021-03-09 21:43:25 +01:00
|
|
|
minetest.override_item(nname, {
|
|
|
|
groups = newgroups
|
|
|
|
})
|
2017-02-10 06:01:20 +01:00
|
|
|
end
|
|
|
|
end
|
2021-03-11 14:49:09 +01:00
|
|
|
|
2023-01-11 19:31:56 +01:00
|
|
|
for tname, tdef in pairs(minetest.registered_items) do
|
2021-03-11 14:49:09 +01:00
|
|
|
-- Assign groupcaps for digging the registered digging groups
|
2021-03-16 20:36:38 +01:00
|
|
|
-- depending on the _mcl_diggroups in the tool definition
|
|
|
|
if tdef._mcl_diggroups then
|
2021-03-17 16:59:26 +01:00
|
|
|
local toolcaps = table.copy(get_tool_capabilities(tdef))
|
2021-03-11 21:52:00 +01:00
|
|
|
toolcaps.groupcaps = mcl_autogroup.get_groupcaps(tname)
|
2021-03-11 14:49:09 +01:00
|
|
|
|
|
|
|
minetest.override_item(tname, {
|
|
|
|
tool_capabilities = toolcaps
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
2017-02-10 06:01:20 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
overwrite()
|