Vanessa's plantlife modpack
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

258 lines
8.2KB

  1. -- Bushes Mod by Mossmanikin, Evergreen, & Neuromancer
  2. -- The initial code for this was taken from Mossmanikin's Grasses Mod, then heavilly modified by Neuromancer for this mod.
  3. -- Mossmanikin also greatly helped with providing samples for coding.
  4. -- bush leaf textures are cc-by-sa 3.0. from VannessaE's moretrees mod. (Leaf texture created by RealBadAngel or VanessaE)
  5. -- Branch textures created by Neuromancer.
  6. -- Licence for Code and Non-Bush leaf code is WTFPL.
  7. abstract_bushes = {}
  8. minetest.register_node("bushes:youngtree2_bottom", {
  9. description = "Young Tree 2 (bottom)",
  10. drawtype="nodebox",
  11. tiles = {"bushes_youngtree2trunk.png"},
  12. inventory_image = "bushes_youngtree2trunk_inv.png",
  13. wield_image = "bushes_youngtree2trunk_inv.png",
  14. paramtype = "light",
  15. walkable = false,
  16. is_ground_content = true,
  17. node_box = {
  18. type = "fixed",
  19. fixed = {
  20. --{0.375000,-0.500000,-0.500000,0.500000,0.500000,-0.375000}, --NodeBox 1
  21. {-0.0612,-0.500000,-0.500000,0.0612,0.500000,-0.375000}, --NodeBox 1
  22. }
  23. },
  24. groups = {snappy=3,flammable=2},
  25. sounds = default.node_sound_leaves_defaults(),
  26. drop = 'default:stick'
  27. })
  28. local BushBranchCenter = { {1,1}, {3,2} }
  29. for i in pairs(BushBranchCenter) do
  30. local Num = BushBranchCenter[i][1]
  31. local TexNum = BushBranchCenter[i][2]
  32. minetest.register_node("bushes:bushbranches"..Num, {
  33. description = "Bush Branches "..Num,
  34. drawtype = "nodebox",
  35. tiles = {
  36. "bushes_leaves_"..TexNum..".png",
  37. "bushes_branches_center_"..TexNum..".png"
  38. },
  39. node_box = {
  40. type = "fixed",
  41. fixed = {
  42. {0, -1/2, -1/2, -1/4, 1/2, 1/2},
  43. {0, -1/2, -1/2, 1/4, 1/2, 1/2}
  44. },
  45. },
  46. selection_box = {
  47. type = "fixed",
  48. fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
  49. },
  50. inventory_image = "bushes_branches_center_"..TexNum..".png",
  51. paramtype = "light",
  52. paramtype2 = "facedir",
  53. sunlight_propagates = true,
  54. groups = {
  55. -- tree=1, -- MM: disabled because some recipes use group:tree for trunks
  56. snappy=3,
  57. flammable=2,
  58. leaves=1
  59. },
  60. sounds = default.node_sound_leaves_defaults(),
  61. drop = 'default:stick 4'
  62. })
  63. end
  64. local BushBranchSide = { {2,1}, {4,2} }
  65. for i in pairs(BushBranchSide) do
  66. local Num = BushBranchSide[i][1]
  67. local TexNum = BushBranchSide[i][2]
  68. minetest.register_node("bushes:bushbranches"..Num, {
  69. description = "Bush Branches "..Num,
  70. drawtype = "nodebox",
  71. tiles = {
  72. --[[top]] "bushes_leaves_"..TexNum..".png",
  73. --[[bottom]]"bushes_branches_center_"..TexNum..".png",
  74. --[[right]] "bushes_branches_left_"..TexNum..".png",
  75. --[[left]] "bushes_branches_right_"..TexNum..".png", -- MM: We could also mirror the previous here,
  76. --[[back]] "bushes_branches_center_"..TexNum..".png",-- unless U really want 'em 2 B different
  77. --[[front]] "bushes_branches_right_"..TexNum..".png"
  78. },
  79. node_box = {
  80. type = "fixed",
  81. fixed = {
  82. -- { left , bottom , front, right , top , back }
  83. {0.137748,-0.491944, 0.5 ,-0.125000,-0.179444,-0.007790}, --NodeBox 1
  84. {0.262748,-0.185995, 0.5 ,-0.237252, 0.126505,-0.260269}, --NodeBox 2
  85. {0.500000, 0.125000, 0.5 ,-0.500000, 0.500000,-0.500000}, --NodeBox 3
  86. },
  87. },
  88. selection_box = {
  89. type = "fixed",
  90. fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
  91. },
  92. inventory_image = "bushes_branches_right_"..TexNum..".png",
  93. paramtype = "light",
  94. paramtype2 = "facedir",
  95. sunlight_propagates = true,
  96. groups = {
  97. -- tree=1, -- MM: disabled because some recipes use group:tree for trunks
  98. snappy=3,
  99. flammable=2,
  100. leaves=1
  101. },
  102. sounds = default.node_sound_leaves_defaults(),
  103. drop = 'default:stick 3'
  104. })
  105. end
  106. local BushLeafNode = { {1}, {2}}
  107. for i in pairs(BushLeafNode) do
  108. local Num = BushLeafNode[i][1]
  109. minetest.register_node("bushes:BushLeaves"..Num, {
  110. description = "Bush Leaves "..Num,
  111. drawtype = "allfaces_optional",
  112. tiles = {"bushes_leaves_"..Num..".png"},
  113. paramtype = "light",
  114. groups = { -- MM: Should we add leafdecay?
  115. snappy=3,
  116. flammable=2,
  117. attached_node=1
  118. },
  119. sounds = default.node_sound_leaves_defaults(),
  120. })
  121. end
  122. abstract_bushes.grow_bush = function(pos)
  123. local leaf_type = math.random(1,2)
  124. local bush_side_height = math.random(0,1)
  125. local chance_of_bush_node_right = math.random(1,10)
  126. if chance_of_bush_node_right> 5 then
  127. local right_pos = {x=pos.x+1, y=pos.y+bush_side_height, z=pos.z}
  128. abstract_bushes.grow_bush_node(right_pos,3,leaf_type)
  129. end
  130. local chance_of_bush_node_left = math.random(1,10)
  131. if chance_of_bush_node_left> 5 then
  132. bush_side_height = math.random(0,1)
  133. local left_pos = {x=pos.x-1, y=pos.y+bush_side_height, z=pos.z}
  134. abstract_bushes.grow_bush_node(left_pos,1,leaf_type)
  135. end
  136. local chance_of_bush_node_front = math.random(1,10)
  137. if chance_of_bush_node_front> 5 then
  138. bush_side_height = math.random(0,1)
  139. local front_pos = {x=pos.x, y=pos.y+bush_side_height, z=pos.z+1}
  140. abstract_bushes.grow_bush_node(front_pos,2,leaf_type)
  141. end
  142. local chance_of_bush_node_back = math.random(1,10)
  143. if chance_of_bush_node_back> 5 then
  144. bush_side_height = math.random(0,1)
  145. local back_pos = {x=pos.x, y=pos.y+bush_side_height, z=pos.z-1}
  146. abstract_bushes.grow_bush_node(back_pos,0,leaf_type)
  147. end
  148. abstract_bushes.grow_bush_node(pos,5,leaf_type)
  149. end
  150. abstract_bushes.grow_bush_node = function(pos,dir, leaf_type)
  151. local right_here = {x=pos.x, y=pos.y+1, z=pos.z}
  152. local above_right_here = {x=pos.x, y=pos.y+2, z=pos.z}
  153. local bush_branch_type = 2
  154. -- MM: I'm not sure if it's slower now than before...
  155. if dir ~= 5 and leaf_type == 1 then
  156. bush_branch_type = 2
  157. end
  158. if dir ~= 5 and leaf_type == 2 then
  159. bush_branch_type = 4
  160. end
  161. if dir == 5 and leaf_type == 1 then
  162. bush_branch_type = 1
  163. dir = 1
  164. end
  165. if dir == 5 and leaf_type == 2 then
  166. bush_branch_type = 3
  167. dir = 1
  168. end
  169. if minetest.get_node(right_here).name == "air" -- instead of check_air = true,
  170. or minetest.get_node(right_here).name == "default:junglegrass" then
  171. minetest.set_node(right_here, {name="bushes:bushbranches"..bush_branch_type , param2=dir})
  172. --minetest.chat_send_all("leaf_type: (" .. leaf_type .. ")")
  173. minetest.set_node(above_right_here, {name="bushes:BushLeaves"..leaf_type})
  174. local chance_of_high_leaves = math.random(1,10)
  175. if chance_of_high_leaves> 5 then
  176. local two_above_right_here = {x=pos.x, y=pos.y+3, z=pos.z}
  177. --minetest.chat_send_all("leaf_type: (" .. leaf_type .. ")")
  178. minetest.set_node(two_above_right_here, {name="bushes:BushLeaves"..leaf_type})
  179. end
  180. end
  181. end
  182. biome_lib:register_generate_plant({
  183. surface = {
  184. "default:dirt_with_grass",
  185. "stoneage:grass_with_silex",
  186. "sumpf:peat",
  187. "sumpf:sumpf"
  188. },
  189. max_count = 15, --10,15
  190. rarity = 101 - 4, --3,4
  191. min_elevation = 1, -- above sea level
  192. plantlife_limit = -0.9,
  193. },
  194. abstract_bushes.grow_bush
  195. )
  196. abstract_bushes.grow_youngtree2 = function(pos)
  197. local height = math.random(4,5)
  198. abstract_bushes.grow_youngtree_node2(pos,height)
  199. end
  200. abstract_bushes.grow_youngtree_node2 = function(pos, height)
  201. local right_here = {x=pos.x, y=pos.y+1, z=pos.z}
  202. local above_right_here = {x=pos.x, y=pos.y+2, z=pos.z}
  203. local two_above_right_here = {x=pos.x, y=pos.y+3, z=pos.z}
  204. local three_above_right_here = {x=pos.x, y=pos.y+4, z=pos.z}
  205. if minetest.get_node(right_here).name == "air" -- instead of check_air = true,
  206. or minetest.get_node(right_here).name == "default:junglegrass" then
  207. if height == 4 then
  208. local two_above_right_here_south = {x=pos.x, y=pos.y+3, z=pos.z-1}
  209. local three_above_right_here_south = {x=pos.x, y=pos.y+4, z=pos.z-1}
  210. minetest.set_node(right_here, {name="bushes:youngtree2_bottom"})
  211. minetest.set_node(above_right_here, {name="bushes:youngtree2_bottom"})
  212. minetest.set_node(two_above_right_here, {name="bushes:bushbranches2" , param2=2})
  213. minetest.set_node(two_above_right_here_south, {name="bushes:bushbranches2" , param2=0})
  214. minetest.set_node(three_above_right_here, {name="bushes:BushLeaves1" })
  215. minetest.set_node(three_above_right_here_south, {name="bushes:BushLeaves1" })
  216. end
  217. end
  218. end
  219. biome_lib:register_generate_plant({
  220. surface = {
  221. "default:dirt_with_grass",
  222. "stoneage:grass_with_silex",
  223. "sumpf:peat",
  224. "sumpf:sumpf"
  225. },
  226. max_count = 55, --10,15
  227. rarity = 101 - 4, --3,4
  228. min_elevation = 1, -- above sea level
  229. plantlife_limit = -0.9,
  230. },
  231. abstract_bushes.grow_youngtree2
  232. )
  233. --http://dev.minetest.net/Node_Drawtypes