Bushes: Add saplings
authorparamat <mat.gregory@virginmedia.com>
Wed, 12 Apr 2017 08:25:21 +0000 (09:25 +0100)
committerparamat <mat.gregory@virginmedia.com>
Wed, 12 Apr 2017 16:18:50 +0000 (17:18 +0100)
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
mods/default/README.txt
mods/default/crafting.lua
mods/default/nodes.lua
mods/default/textures/default_acacia_bush_sapling.png [new file with mode: 0644]
mods/default/textures/default_bush_sapling.png [new file with mode: 0644]
mods/default/trees.lua

index d9b88f48689d08473c1a3981bb237e3e42026b6d..8b6bf8399fccf89214ad26b6102912fd92cae25d 100644 (file)
@@ -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
 -----
index 4e41479afa33073d3d25181e718c6530efbfa212..fc6def98d35bdc8d7b3f29d9b7c5de7fdcaa0858 100644 (file)
@@ -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
index 1eca8887551aef6c6234aa9702f62a992cf11beb..721f4132bc12917e30d196f444814d93c2a88997 100644 (file)
@@ -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",
index db679830971860c91d4ae0ea3dc6e9578d72b786..b7309e1204fa3660ef1b9cbdd45b05576264606a 100644 (file)
@@ -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 (file)
index 0000000..940b3aa
Binary files /dev/null and b/mods/default/textures/default_acacia_bush_sapling.png differ
diff --git a/mods/default/textures/default_bush_sapling.png b/mods/default/textures/default_bush_sapling.png
new file mode 100644 (file)
index 0000000..905ba4b
Binary files /dev/null and b/mods/default/textures/default_bush_sapling.png differ
index 0b829a7585985a0e59e7a4fec7becdb9b0bbe6d2..81c9831e63bf9c8a3422c4960b8563ba680fd960 100644 (file)
@@ -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
 --