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",
|
2015-08-15 23:23:44 +02:00
|
|
|
groups = { snappy = 3, leafdecay = 3, flammable = 2, leafdecay = 3 },
|
2014-07-04 06:49:32 +02:00
|
|
|
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
|
2015-06-18 09:36:17 +02:00
|
|
|
-- Limit mass changes after block has not been loaded for some time:
|
|
|
|
-- Run ABM with higher frequency, but don't enqueue all blocks
|
2014-07-04 06:49:32 +02:00
|
|
|
minetest.register_abm({
|
2015-02-09 05:17:02 +01:00
|
|
|
nodenames = { nature.blossom_leaves },
|
2015-06-18 09:36:17 +02:00
|
|
|
interval = nature.blossom_delay / nature.leaves_blossom_chance,
|
2015-04-02 12:18:09 +02:00
|
|
|
chance = nature.leaves_blossom_chance,
|
2014-07-04 06:49:32 +02:00
|
|
|
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2015-06-18 09:36:17 +02:00
|
|
|
if math.random(nature.leaves_blossom_chance) == 1 then
|
|
|
|
nature.enqueue_node(pos, node, nature.blossom_node)
|
|
|
|
end
|
2014-07-04 06:49:32 +02:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2015-02-09 05:17:02 +01:00
|
|
|
-- Removing blossoms
|
2015-06-18 09:36:17 +02:00
|
|
|
-- Limit mass changes after block has not been loaded for some time:
|
|
|
|
-- Run ABM with higher frequency, but don't enqueue all blocks
|
2014-07-04 06:49:32 +02:00
|
|
|
minetest.register_abm({
|
2015-02-09 05:17:02 +01:00
|
|
|
nodenames = { nature.blossom_node },
|
2015-06-18 09:36:17 +02:00
|
|
|
interval = nature.blossom_delay / nature.blossom_leaves_chance,
|
2015-04-02 12:18:09 +02:00
|
|
|
chance = nature.blossom_leaves_chance,
|
2014-07-04 06:49:32 +02:00
|
|
|
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2015-06-18 09:36:17 +02:00
|
|
|
if math.random(nature.blossom_leaves_chance) == 1 then
|
|
|
|
nature.enqueue_node(pos, node, nature.blossom_leaves)
|
|
|
|
end
|
2014-07-04 06:49:32 +02:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Spawning apples
|
2015-06-18 09:36:17 +02:00
|
|
|
-- Limit mass changes after block has not been loaded for some time:
|
|
|
|
-- spawn apples with 10% chance, but with 10 times higher frequency
|
2014-07-04 06:49:32 +02:00
|
|
|
minetest.register_abm({
|
2015-02-09 05:17:02 +01:00
|
|
|
nodenames = { nature.blossom_node },
|
2015-11-03 12:32:59 +01:00
|
|
|
interval = nature.apple_delay / 10,
|
2015-02-09 05:17:02 +01:00
|
|
|
chance = nature.apple_chance,
|
2014-07-04 06:49:32 +02:00
|
|
|
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2015-11-03 12:30:13 +01:00
|
|
|
if math.random(10) == 1 and 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
|
|
|
|
})
|