Automatically assign nodes to creative_breakable

If they belong to any digging group.
This commit is contained in:
Elias Åström 2021-03-17 17:50:52 +01:00
parent 8f9650abe4
commit c8b543991f
2 changed files with 21 additions and 24 deletions

View File

@ -311,9 +311,12 @@ local overwrite = function()
newgroups.opaque = 1
end
local creative_breakable = false
-- Assign groups used for digging this node depending on
-- the registered digging groups
for g, gdef in pairs(mcl_autogroup.registered_diggroups) do
creative_breakable = true
local index = hardness_lookup[g][ndef._mcl_hardness or 0]
if ndef.groups[g] then
if gdef.levels then
@ -328,6 +331,11 @@ local overwrite = function()
end
end
-- Automatically assign the node to the
-- creative_breakable group if it belongs to any digging
-- group.
newgroups["creative_breakable"] = 1
minetest.override_item(nname, {
groups = newgroups
})

View File

@ -19,35 +19,14 @@ dig_speed_class group:
-- The hand
local groupcaps, hand_range, hand_groups
if minetest.is_creative_enabled("") then
-- Instant breaking in creative mode
groupcaps = {}
groupcaps = { creative_breakable = { times = {0}, uses = 0 } }
hand_range = 10
hand_groups = { dig_speed_class = 7 }
hand_autogroup_groupcaps = {
handy = { tool_multiplier = 1000, level = 1, uses = 0 },
axey = { tool_multiplier = 1000, level = 1, uses = 0 },
pickaxey = { tool_multiplier = 1000, level = 5, uses = 0 },
shovely = { tool_multiplier = 1000, level = 1, uses = 0 },
swordy = { tool_multiplier = 1000, level = 1, uses = 0 },
swordy_cobweb = { tool_multiplier = 1000, level = 1, uses = 0 },
shearsy = { tool_multiplier = 1000, level = 1, uses = 0 },
shearsy_wool = { tool_multiplier = 1000, level = 1, uses = 0 },
shearsy_cobweb = { tool_multiplier = 1000, level = 1, uses = 0 },
}
else
groupcaps = {}
hand_autogroup_groupcaps = {
handy = { tool_multiplier = 1, level = 1, uses = 0 },
axey = { tool_multiplier = 1, level = 1, uses = 0 },
shovely = { tool_multiplier = 1, level = 1, uses = 0 },
pickaxey = { tool_multiplier = 1, level = 0, uses = 0 },
swordy = { tool_multiplier = 1, level = 0, uses = 0 },
swordy_cobweb = { tool_multiplier = 1, level = 0, uses = 0 },
shearsy = { tool_multiplier = 1, level = 0, uses = 0 },
shearsy_wool = { tool_multiplier = 1, level = 0, uses = 0 },
shearsy_cobweb = { tool_multiplier = 1, level = 0, uses = 0 },
}
hand_range = 4
hand_groups = { dig_speed_class = 1 }
end
@ -68,7 +47,17 @@ minetest.register_tool(":", {
damage_groups = {fleshy=1},
},
groups = hand_groups,
_mcl_diggroups = hand_autogroup_groupcaps,
_mcl_diggroups = {
handy = { tool_multiplier = 1, level = 1, uses = 0 },
axey = { tool_multiplier = 1, level = 1, uses = 0 },
shovely = { tool_multiplier = 1, level = 1, uses = 0 },
pickaxey = { tool_multiplier = 1, level = 0, uses = 0 },
swordy = { tool_multiplier = 1, level = 0, uses = 0 },
swordy_cobweb = { tool_multiplier = 1, level = 0, uses = 0 },
shearsy = { tool_multiplier = 1, level = 0, uses = 0 },
shearsy_wool = { tool_multiplier = 1, level = 0, uses = 0 },
shearsy_cobweb = { tool_multiplier = 1, level = 0, uses = 0 },
}
})
-- Help texts