2015-02-09 05:17:02 +01:00
|
|
|
-- Blossoms and such
|
2014-07-05 07:56:06 +02:00
|
|
|
|
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
|
2014-08-16 01:34:15 +02:00
|
|
|
minetest.set_node(below, { name = "default:apple" })
|
2014-07-04 06:49:32 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-02-09 05:17:02 +01:00
|
|
|
minetest.register_node(":"..nature.blossom_node, {
|
2014-07-30 18:39:43 +02:00
|
|
|
description = "Apple blossoms",
|
2014-07-04 06:49:32 +02:00
|
|
|
drawtype = "allfaces_optional",
|
2015-02-09 05:17:02 +01:00
|
|
|
tiles = nature.blossom_textures,
|
2014-07-04 06:49:32 +02:00
|
|
|
paramtype = "light",
|
|
|
|
groups = { snappy = 3, leafdecay = 3, flammable = 2 },
|
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
2014-07-04 07:44:15 +02:00
|
|
|
waving = 1
|
2014-07-04 06:49:32 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
type = "fuel",
|
2015-02-09 05:17:02 +01:00
|
|
|
recipe = nature.blossom_node,
|
2014-07-04 06:49:32 +02:00
|
|
|
burntime = 2,
|
|
|
|
})
|
|
|
|
|
2015-02-09 05:17:02 +01:00
|
|
|
-- these ABMs can get heavy, so just enqueue the nodes
|
|
|
|
|
|
|
|
-- Adding Blossoms
|
2014-07-04 06:49:32 +02:00
|
|
|
minetest.register_abm({
|
2015-02-09 05:17:02 +01:00
|
|
|
nodenames = { nature.blossom_leaves },
|
|
|
|
interval = nature.blossom_delay,
|
|
|
|
chance = nature.blossom_chance,
|
2014-07-04 06:49:32 +02:00
|
|
|
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2015-04-02 12:16:50 +02:00
|
|
|
nature.enqueue_node(pos, node, nature.blossom_node)
|
2014-07-04 06:49:32 +02:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2015-02-09 05:17:02 +01:00
|
|
|
-- Removing blossoms
|
2014-07-04 06:49:32 +02:00
|
|
|
minetest.register_abm({
|
2015-02-09 05:17:02 +01:00
|
|
|
nodenames = { nature.blossom_node },
|
|
|
|
interval = nature.blossom_delay,
|
|
|
|
chance = nature.blossom_chance,
|
2014-07-04 06:49:32 +02:00
|
|
|
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2015-04-02 12:16:50 +02:00
|
|
|
nature.enqueue_node(pos, node, nature.blossom_leaves)
|
2014-07-04 06:49:32 +02:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Spawning apples
|
|
|
|
minetest.register_abm({
|
2015-02-09 05:17:02 +01:00
|
|
|
nodenames = { nature.blossom_node },
|
|
|
|
interval = nature.blossom_delay,
|
|
|
|
chance = nature.apple_chance,
|
2014-07-04 06:49:32 +02:00
|
|
|
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2015-02-09 05:17:02 +01:00
|
|
|
if nature.dtime < 0.2 and not minetest.find_node_near(pos, nature.apple_spread, { "default:apple" }) then
|
2014-07-05 07:56:06 +02:00
|
|
|
spawn_apple_under(pos)
|
|
|
|
end
|
2014-07-04 06:49:32 +02:00
|
|
|
end
|
|
|
|
})
|