Skip to content

Commit

Permalink
Bushes: Add saplings
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
paramat committed Apr 12, 2017
1 parent d68d2c0 commit a57d2db
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 3 deletions.
10 changes: 8 additions & 2 deletions game_api.txt
Expand Up @@ -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
-----
Expand Down
4 changes: 3 additions & 1 deletion mods/default/README.txt
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions mods/default/crafting.lua
Expand Up @@ -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",
Expand Down
86 changes: 86 additions & 0 deletions mods/default/nodes.lua
Expand Up @@ -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
------
Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mods/default/textures/default_bush_sapling.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions mods/default/trees.lua
Expand Up @@ -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

Expand Down Expand Up @@ -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
--
Expand Down

0 comments on commit a57d2db

Please sign in to comment.