2022-02-05 01:01:23 +02:00
|
|
|
local S = minetest.get_translator(minetest.get_current_modname())
|
|
|
|
|
2022-02-05 04:27:23 +02:00
|
|
|
local interval = 10
|
|
|
|
local chance = 5
|
|
|
|
|
|
|
|
local function grow(pos, node)
|
2022-02-05 00:39:40 +02:00
|
|
|
local def = minetest.registered_nodes[node.name]
|
|
|
|
local next_gen = def._mcl_amethyst_next_grade
|
2022-02-05 01:01:23 +02:00
|
|
|
if not next_gen then return end
|
|
|
|
|
2022-02-05 04:27:23 +02:00
|
|
|
local dir = minetest.wallmounted_to_dir(node.param2)
|
|
|
|
local ba_pos = vector.add(pos, dir)
|
|
|
|
local ba_node = minetest.get_node(ba_pos)
|
|
|
|
if ba_node.name ~= "mcl_amethyst:budding_amethyst_block" then return end
|
|
|
|
|
2022-02-05 00:39:40 +02:00
|
|
|
local swap_result = table.copy(node)
|
|
|
|
swap_result.name = next_gen
|
2022-02-05 01:01:23 +02:00
|
|
|
minetest.swap_node(pos, swap_result)
|
2021-07-28 15:44:30 +03:00
|
|
|
end
|
|
|
|
|
2022-02-05 04:27:23 +02:00
|
|
|
minetest.register_abm({
|
|
|
|
label = "Amethyst Bud Growth",
|
|
|
|
nodenames = {"group:amethyst_buds"},
|
|
|
|
neighbors = {"mcl_amethyst:budding_amethyst_block"},
|
|
|
|
interval = interval,
|
|
|
|
chance = chance,
|
|
|
|
action = grow,
|
2021-07-28 15:44:30 +03:00
|
|
|
})
|
2022-02-05 01:01:23 +02:00
|
|
|
|
2022-02-05 04:27:23 +02:00
|
|
|
local all_directions = {
|
|
|
|
vector.new(1,0,0),
|
|
|
|
vector.new(0,1,0),
|
|
|
|
vector.new(0,0,1),
|
|
|
|
vector.new(-1,0,0),
|
|
|
|
vector.new(0,-1,0),
|
|
|
|
vector.new(0,0,-1),
|
|
|
|
}
|
|
|
|
|
|
|
|
minetest.register_abm({
|
|
|
|
label = "Spawn Amethyst Bud",
|
|
|
|
nodenames = {"mcl_amethyst:budding_amethyst_block"},
|
|
|
|
neighbors = {"air", "group:water"},
|
|
|
|
interval = 20,
|
|
|
|
chance = 2,
|
|
|
|
action = function(pos)
|
|
|
|
local check_pos = vector.add(all_directions[math.random(1, #all_directions)], pos)
|
|
|
|
local check_node = minetest.get_node(check_pos)
|
|
|
|
local check_node_name = check_node.name
|
|
|
|
if check_node_name ~= "air" and minetest.get_item_group(check_node_name, "water") == 0 then return end
|
|
|
|
local param2 = minetest.dir_to_wallmounted(vector.subtract(pos, check_pos))
|
2022-02-06 02:32:44 +02:00
|
|
|
local new_node = {name = "mcl_amethyst:small_amethyst_bud", param2 = param2}
|
2022-02-05 04:27:23 +02:00
|
|
|
minetest.swap_node(check_pos, new_node)
|
|
|
|
end,
|
|
|
|
})
|