2017-08-03 15:02:56 +02:00
|
|
|
-- support for i18n
|
2020-02-15 15:32:06 +01:00
|
|
|
local S = minetest.get_translator("nature_classic")
|
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
|
2018-10-25 16:27:54 +02:00
|
|
|
minetest.swap_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, {
|
2017-08-03 15:02:56 +02:00
|
|
|
description = S("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",
|
2017-03-31 00:29:24 +02:00
|
|
|
groups = nature.blossom_groups,
|
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
|
|
|
})
|
|
|
|
|
2017-03-31 00:29:24 +02:00
|
|
|
default.register_leafdecay({
|
|
|
|
trunks = { nature.blossom_trunk },
|
2017-08-13 01:59:19 +02:00
|
|
|
leaves = { nature.blossom_node, nature.blossom_leaves },
|
2017-03-31 00:29:24 +02:00
|
|
|
radius = nature.blossom_decay,
|
|
|
|
})
|
|
|
|
|
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:
|
2015-11-03 12:31:20 +01:00
|
|
|
-- spawn apples with 25% chance, but with 4 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:31:20 +01:00
|
|
|
interval = nature.apple_delay / 4,
|
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:31:20 +01:00
|
|
|
if math.random(4) == 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
|
|
|
|
})
|