From a57d2db54a2d151da48e3ee4b2419ed3961a2d4b Mon Sep 17 00:00:00 2001 From: paramat Date: Wed, 12 Apr 2017 09:25:21 +0100 Subject: [PATCH] Bushes: Add saplings Bush saplings grow in half the time of tree saplings. Bushes do not need 'from sapling' schematic variants because only the stem node is force-placed in the mapgen schematic, so only the sapling is force-replaced. Bush leaves drop saplings with a rarity that ensures at least 1 sapling per bush on average. --- game_api.txt | 10 +- mods/default/README.txt | 4 +- mods/default/crafting.lua | 12 +++ mods/default/nodes.lua | 86 ++++++++++++++++++ .../textures/default_acacia_bush_sapling.png | Bin 0 -> 151 bytes .../default/textures/default_bush_sapling.png | Bin 0 -> 165 bytes mods/default/trees.lua | 31 +++++++ 7 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 mods/default/textures/default_acacia_bush_sapling.png create mode 100644 mods/default/textures/default_bush_sapling.png diff --git a/game_api.txt b/game_api.txt index d9b88f48..8b6bf839 100644 --- a/game_api.txt +++ b/game_api.txt @@ -766,14 +766,20 @@ Trees * `default.grow_new_pine_tree(pos)` * Grows a new design pine tree at pos + * `default.grow_new_snowy_pine_tree(pos)` + * Grows a new design snowy pine tree at pos + * `default.grow_new_acacia_tree(pos)` * Grows a new design acacia tree at pos * `default.grow_new_aspen_tree(pos)` * Grows a new design aspen tree at pos - * `default.grow_new_snowy_pine_tree(pos)` - * Grows a new design snowy pine tree at pos + * `default.grow_bush(pos)` + * Grows a bush at pos + + * `default.grow_acacia_bush(pos)` + * Grows an acaia bush at pos Carts ----- diff --git a/mods/default/README.txt b/mods/default/README.txt index 4e41479a..fc6def98 100644 --- a/mods/default/README.txt +++ b/mods/default/README.txt @@ -17,6 +17,7 @@ Cisoun's texture pack (CC BY-SA 3.0): default_lava.png default_leaves.png default_sapling.png + default_bush_sapling.png default_stone.png default_tree.png default_tree_top.png @@ -90,6 +91,7 @@ paramat (CC BY-SA 3.0): default_acacia_leaves.png default_acacia_leaves_simple.png default_acacia_sapling.png + default_acacia_bush_sapling.png default_acacia_tree.png default_acacia_tree_top.png default_acacia_wood.png @@ -126,7 +128,7 @@ brunob.santos (CC BY-SA 4.0): default_desert_cobble.png BlockMen (CC BY-SA 3.0): - default_aspen_leaves.png + default_aspen_leaves.png -- Derived from Sofar's texture default_wood.png default_clay_brick.png default_iron_ingot.png diff --git a/mods/default/crafting.lua b/mods/default/crafting.lua index 1eca8887..721f4132 100644 --- a/mods/default/crafting.lua +++ b/mods/default/crafting.lua @@ -966,6 +966,18 @@ minetest.register_craft({ burntime = 10, }) +minetest.register_craft({ + type = "fuel", + recipe = "default:bush_sapling", + burntime = 6, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "default:acacia_bush_sapling", + burntime = 7, +}) + minetest.register_craft({ type = "fuel", recipe = "default:aspen_sapling", diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index db679830..b7309e12 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -140,8 +140,10 @@ default:dry_grass_5 default:bush_stem default:bush_leaves +default:bush_sapling default:acacia_bush_stem default:acacia_bush_leaves +default:acacia_bush_sapling Corals ------ @@ -1307,11 +1309,53 @@ minetest.register_node("default:bush_leaves", { tiles = {"default_leaves_simple.png"}, paramtype = "light", groups = {snappy = 3, flammable = 2, leaves = 1}, + drop = { + max_items = 1, + items = { + {items = {"default:bush_sapling"}, rarity = 5}, + {items = {"default:bush_leaves"}} + } + }, sounds = default.node_sound_leaves_defaults(), after_place_node = default.after_place_leaves, }) +minetest.register_node("default:bush_sapling", { + description = "Bush Sapling", + drawtype = "plantlike", + tiles = {"default_bush_sapling.png"}, + inventory_image = "default_bush_sapling.png", + wield_image = "default_bush_sapling.png", + paramtype = "light", + sunlight_propagates = true, + walkable = false, + on_timer = default.grow_sapling, + selection_box = { + type = "fixed", + fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 2 / 16, 4 / 16} + }, + groups = {snappy = 2, dig_immediate = 3, flammable = 2, + attached_node = 1, sapling = 1}, + sounds = default.node_sound_leaves_defaults(), + + on_construct = function(pos) + minetest.get_node_timer(pos):start(math.random(1200, 2400)) + end, + + on_place = function(itemstack, placer, pointed_thing) + itemstack = default.sapling_on_place(itemstack, placer, pointed_thing, + "default:bush_sapling", + -- minp, maxp to be checked, relative to sapling pos + {x = -1, y = 0, z = -1}, + {x = 1, y = 1, z = 1}, + -- maximum interval of interior volume check + 2) + + return itemstack + end, +}) + minetest.register_node("default:acacia_bush_stem", { description = "Acacia Bush Stem", drawtype = "plantlike", @@ -1336,11 +1380,53 @@ minetest.register_node("default:acacia_bush_leaves", { tiles = {"default_acacia_leaves_simple.png"}, paramtype = "light", groups = {snappy = 3, flammable = 2, leaves = 1}, + drop = { + max_items = 1, + items = { + {items = {"default:acacia_bush_sapling"}, rarity = 5}, + {items = {"default:acacia_bush_leaves"}} + } + }, sounds = default.node_sound_leaves_defaults(), after_place_node = default.after_place_leaves, }) +minetest.register_node("default:acacia_bush_sapling", { + description = "Acacia Bush Sapling", + drawtype = "plantlike", + tiles = {"default_acacia_bush_sapling.png"}, + inventory_image = "default_acacia_bush_sapling.png", + wield_image = "default_acacia_bush_sapling.png", + paramtype = "light", + sunlight_propagates = true, + walkable = false, + on_timer = default.grow_sapling, + selection_box = { + type = "fixed", + fixed = {-3 / 16, -0.5, -3 / 16, 3 / 16, 2 / 16, 3 / 16} + }, + groups = {snappy = 2, dig_immediate = 3, flammable = 2, + attached_node = 1, sapling = 1}, + sounds = default.node_sound_leaves_defaults(), + + on_construct = function(pos) + minetest.get_node_timer(pos):start(math.random(1200, 2400)) + end, + + on_place = function(itemstack, placer, pointed_thing) + itemstack = default.sapling_on_place(itemstack, placer, pointed_thing, + "default:acacia_bush_sapling", + -- minp, maxp to be checked, relative to sapling pos + {x = -1, y = 0, z = -1}, + {x = 1, y = 1, z = 1}, + -- maximum interval of interior volume check + 2) + + return itemstack + end, +}) + -- -- Corals diff --git a/mods/default/textures/default_acacia_bush_sapling.png b/mods/default/textures/default_acacia_bush_sapling.png new file mode 100644 index 0000000000000000000000000000000000000000..940b3aacb8df878a5d49d274791cff1c396066f5 GIT binary patch literal 151 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPE^3h)VWP0r8pbG3^J3&_hz@T$~{ zoUhk5?e`m?EMrNKUoeBivm0qZjD(XY_i3u<=T%O449&%cs6ley6r>mdK II;Vst06Lv3;{X5v literal 0 HcmV?d00001 diff --git a/mods/default/trees.lua b/mods/default/trees.lua index 0b829a75..81c9831e 100644 --- a/mods/default/trees.lua +++ b/mods/default/trees.lua @@ -77,6 +77,14 @@ function default.grow_sapling(pos) minetest.log("action", "An aspen sapling grows into a tree at ".. minetest.pos_to_string(pos)) default.grow_new_aspen_tree(pos) + elseif node.name == "default:bush_sapling" then + minetest.log("action", "A bush sapling grows into a bush at ".. + minetest.pos_to_string(pos)) + default.grow_bush(pos) + elseif node.name == "default:acacia_bush_sapling" then + minetest.log("action", "An acacia bush sapling grows into a bush at ".. + minetest.pos_to_string(pos)) + default.grow_acacia_bush(pos) end end @@ -426,6 +434,29 @@ function default.grow_new_aspen_tree(pos) end +-- Bushes do not need 'from sapling' schematic variants because +-- only the stem node is force-placed in the schematic. + +-- Bush + +function default.grow_bush(pos) + local path = minetest.get_modpath("default") .. + "/schematics/bush.mts" + minetest.place_schematic({x = pos.x - 1, y = pos.y - 1, z = pos.z - 1}, + path, "0", nil, false) +end + + +-- Acacia bush + +function default.grow_acacia_bush(pos) + local path = minetest.get_modpath("default") .. + "/schematics/acacia_bush.mts" + minetest.place_schematic({x = pos.x - 1, y = pos.y - 1, z = pos.z - 1}, + path, "0", nil, false) +end + + -- -- Sapling 'on place' function to check protection of node and resulting tree volume -- -- 2.25.1