2014-07-04 06:49:32 +02:00
|
|
|
-- Blossom
|
|
|
|
|
|
|
|
local BLOSSOM_CHANCE = 15
|
|
|
|
local BLOSSOM_DELAY = 3600
|
|
|
|
local BLOSSOM_NODE = "nature:blossom"
|
|
|
|
|
2014-07-05 07:56:06 +02:00
|
|
|
local APPLE_CHANCE = 10
|
|
|
|
local APPLE_SPREAD = 2
|
|
|
|
|
2014-07-04 06:49:32 +02:00
|
|
|
local function spawn_apple_under(pos)
|
|
|
|
local below = {
|
|
|
|
x = pos.x,
|
|
|
|
y = pos.y - 1,
|
|
|
|
z = pos.z,
|
|
|
|
}
|
2014-07-05 08:01:24 +02:00
|
|
|
if minetest.get_node(below).name == "air" then
|
|
|
|
minetest.add_node(below, { name = "default:apple" })
|
2014-07-04 06:49:32 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_node(":"..BLOSSOM_NODE, {
|
|
|
|
description = "Blossom",
|
|
|
|
drawtype = "allfaces_optional",
|
|
|
|
tiles = { "default_leaves.png^nature_blossom.png" },
|
|
|
|
paramtype = "light",
|
|
|
|
groups = { snappy = 3, leafdecay = 3, flammable = 2 },
|
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
drop = BLOSSOM_NODE,
|
2014-07-04 07:44:15 +02:00
|
|
|
waving = 1
|
2014-07-04 06:49:32 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
type = "fuel",
|
|
|
|
recipe = BLOSSOM_NODE,
|
|
|
|
burntime = 2,
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Blossoming
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = { "default:leaves" },
|
|
|
|
interval = BLOSSOM_DELAY,
|
|
|
|
chance = BLOSSOM_CHANCE,
|
|
|
|
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2014-07-05 07:46:33 +02:00
|
|
|
if nature:is_near_water(pos) then
|
|
|
|
nature:grow_node(pos, BLOSSOM_NODE)
|
|
|
|
end
|
2014-07-04 06:49:32 +02:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Removing blossom
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = { BLOSSOM_NODE },
|
|
|
|
interval = BLOSSOM_DELAY,
|
|
|
|
chance = BLOSSOM_CHANCE,
|
|
|
|
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
|
|
nature:grow_node(pos, "default:leaves")
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Spawning apples
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = { BLOSSOM_NODE },
|
|
|
|
interval = BLOSSOM_DELAY,
|
|
|
|
chance = APPLE_CHANCE,
|
|
|
|
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2014-07-05 07:56:06 +02:00
|
|
|
if not minetest.find_node_near(pos, APPLE_SPREAD, { "default:apple" }) then
|
|
|
|
spawn_apple_under(pos)
|
|
|
|
end
|
2014-07-04 06:49:32 +02:00
|
|
|
end
|
|
|
|
})
|