2023-10-11 08:28:23 +00:00
|
|
|
local modname = minetest.get_current_modname()
|
|
|
|
|
2023-10-17 13:05:40 +00:00
|
|
|
local function is_stoney_below (pos)
|
|
|
|
local below_node = minetest.get_node(pos + blockgame.vector.dirs.down)
|
|
|
|
return blockgame.item_matches(below_node.name, {"group:stoney"})
|
|
|
|
end
|
|
|
|
|
2023-10-11 09:40:41 +00:00
|
|
|
blockgame.crafting.register_pummel_recipe({
|
2023-10-17 12:53:08 +00:00
|
|
|
name = modname .. ":craft_tile",
|
2023-10-11 09:40:41 +00:00
|
|
|
label = "pummel stone into tile",
|
2023-10-17 12:53:08 +00:00
|
|
|
used = {"group:stoney"},
|
|
|
|
target = {"bg_terrain:cobblestone"},
|
2023-10-11 09:40:41 +00:00
|
|
|
check = function (pos, used_node, target_node)
|
2023-10-17 13:05:40 +00:00
|
|
|
return is_stoney_below(pos)
|
2023-10-11 09:40:41 +00:00
|
|
|
end,
|
|
|
|
on_success = function (pos, used_node, target_node)
|
|
|
|
minetest.set_node(pos, {name = modname .. ":tile"})
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
blockgame.crafting.register_pummel_recipe({
|
2023-10-17 12:53:08 +00:00
|
|
|
name = modname .. ":craft_bricks",
|
2023-10-11 09:40:41 +00:00
|
|
|
label = "pummel tile into bricks",
|
2023-10-17 12:53:08 +00:00
|
|
|
used = {"group:stoney"},
|
|
|
|
target = {modname .. ":tile"},
|
2023-10-11 09:40:41 +00:00
|
|
|
check = function (pos, used_node, target_node)
|
2023-10-17 13:05:40 +00:00
|
|
|
return is_stoney_below(pos)
|
2023-10-11 09:40:41 +00:00
|
|
|
end,
|
|
|
|
on_success = function (pos, used_node, target_node)
|
|
|
|
minetest.set_node(pos, {name = modname .. ":bricks"})
|
|
|
|
end,
|
|
|
|
})
|
2023-10-19 09:30:45 +00:00
|
|
|
|
|
|
|
local crush_recipes = {
|
|
|
|
{
|
|
|
|
input = {"bg_terrain:cobblestone", "bg_terrain:cobblestone_loose"},
|
|
|
|
output = modname .. ":tile",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input = {modname .. ":tile"},
|
|
|
|
output = modname .. ":bricks",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
blockgame.register_after_falling_node_lands(function (pos, node, entity)
|
|
|
|
if not blockgame.item_matches(node.name, {"group:stoney"}) then return end
|
|
|
|
|
|
|
|
local def = minetest.registered_nodes[node.name]
|
|
|
|
local mass = def.mass or 1
|
|
|
|
local force = math.abs(entity.fall_velocity.y) * mass
|
|
|
|
|
|
|
|
if force < 5 then return end
|
|
|
|
|
|
|
|
local below = pos + blockgame.vector.dirs.down
|
|
|
|
local target = minetest.get_node(below).name
|
|
|
|
if not blockgame.item_matches(target, {"group:stoney"}) then return end
|
|
|
|
|
|
|
|
for _, recipe in pairs(crush_recipes) do
|
|
|
|
local input = recipe.input
|
|
|
|
local output = recipe.output
|
|
|
|
if blockgame.item_matches(target, input) then
|
|
|
|
minetest.set_node(below, {name = output})
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|