From 2a42871ad90fb299cbc743087faf7023089a5dac Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Fri, 12 Aug 2016 22:58:34 +0200 Subject: [PATCH] [bushes] Add young tree seed; fix #465 --- mods/plantlife_modpack/bushes/init.lua | 38 ++++++++++++++++-- .../bushes/textures/bushes_youngtree.png | Bin 0 -> 146 bytes 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 mods/plantlife_modpack/bushes/textures/bushes_youngtree.png diff --git a/mods/plantlife_modpack/bushes/init.lua b/mods/plantlife_modpack/bushes/init.lua index 977fcfb6..948b09af 100755 --- a/mods/plantlife_modpack/bushes/init.lua +++ b/mods/plantlife_modpack/bushes/init.lua @@ -210,13 +210,24 @@ biome_lib:register_generate_plant({ abstract_bushes.grow_bush ) - abstract_bushes.grow_youngtree2 = function(pos) + abstract_bushes.grow_youngtree2 = function(pos,unforceful) local height = math.random(4,5) - abstract_bushes.grow_youngtree_node2(pos,height) + return abstract_bushes.grow_youngtree_node2(pos,height,unforceful) end -abstract_bushes.grow_youngtree_node2 = function(pos, height) +abstract_bushes.grow_youngtree_node2 = function(pos, height,unforceful) + if unforceful then + for y = 1, 4 do + local m = 0 + if (y > 2) then m = 1 end + for z = 0, m do + if minetest.get_node({x = pos.x, y = pos.y+y, z = pos.z+z}).name ~= "air" then + return + end + end + end + end local right_here = {x=pos.x, y=pos.y+1, z=pos.z} local above_right_here = {x=pos.x, y=pos.y+2, z=pos.z} @@ -234,11 +245,32 @@ abstract_bushes.grow_youngtree_node2 = function(pos, height) minetest.set_node(two_above_right_here_south, {name="bushes:bushbranches2" , param2=0}) minetest.set_node(three_above_right_here, {name="bushes:BushLeaves1" }) minetest.set_node(three_above_right_here_south, {name="bushes:BushLeaves1" }) + return true end end end +minetest.register_craftitem("bushes:youngtree", { + description = "Young tree", + inventory_image = "bushes_youngtree.png", + on_use = function(stack, _, pointed_thing) + if (pointed_thing.type ~= "node") then return end + if (abstract_bushes.grow_youngtree2(pointed_thing.under, true)) then + stack:set_count(stack:get_count() - 1) + return stack + end + end, +}) + +minetest.register_craft({ + output = "bushes:youngtree", + recipe = { + {"bushes:BushLeaves1", "default:stick", "bushes:BushLeaves1"}, + {"", "default:stick", ""}, + {"", "default:stick", ""}, + }, +}) biome_lib:register_generate_plant({ surface = { diff --git a/mods/plantlife_modpack/bushes/textures/bushes_youngtree.png b/mods/plantlife_modpack/bushes/textures/bushes_youngtree.png new file mode 100644 index 0000000000000000000000000000000000000000..d4a7cfa899fdc4c1844e6154da75609240af1e37 GIT binary patch literal 146 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k)AG&Ar`&KDG5MuHvPwW2eu!! z6B{RX%JiOKSkJg$-N+y)g(2JSaJ^HTz!#>I50jU#`*YtfR?=BmuW%8MqNnjDwVa$u s4f8wi)!Pf(?wOT2o6n7R!DL1TPHyQv(=IqC0WD$hboFyt=akR{0GA3dZ2$lO literal 0 HcmV?d00001