oak.lua 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. moretrees = moretrees or {}
  2. local SAPLING_TIME_MIN = 60*10
  3. local SAPLING_TIME_MAX = 60*15
  4. local SAPLING_CHANCE = 40
  5. local SCHEMATIC_MINP = {x=-4, y=0, z=-4}
  6. local SCHEMATIC_MAXP = {x=4, y=12, z=4}
  7. local SCHEMATIC_RELP = {x=-4, y=0, z=-4}
  8. -- Localize for performance.
  9. local math_random = math.random
  10. minetest.register_node("moretrees:oak_tree", {
  11. drawtype = "nodebox",
  12. paramtype = "light",
  13. node_box = {
  14. type = "fixed",
  15. fixed = basictrees.trunk_nodebox,
  16. },
  17. description = "Oak Tree",
  18. tiles = {
  19. "moretrees_oak_trunk_top.png",
  20. "moretrees_oak_trunk_top.png",
  21. "moretrees_oak_trunk.png"
  22. },
  23. paramtype2 = "facedir",
  24. groups = moretrees.tree_groups,
  25. sounds = default.node_sound_wood_defaults(),
  26. on_place = minetest.rotate_node,
  27. movement_speed_multiplier = default.NORM_SPEED,
  28. on_destruct = enhanced_leafdecay.make_tree_destructor({
  29. leaves = {
  30. "moretrees:oak_leaves",
  31. "moretrees:oak_acorn",
  32. "group:dry_leaves",
  33. },
  34. }),
  35. })
  36. minetest.register_node("moretrees:oak_leaves", {
  37. description = "Oak Leaves",
  38. drawtype = "allfaces_optional",
  39. visual_scale = 1.3,
  40. waving = 1,
  41. tiles = {"moretrees_oak_leaves.png"},
  42. paramtype = "light",
  43. groups = moretrees.leaves_groups,
  44. drop = moretrees.get_leafdrop_table(SAPLING_CHANCE, "moretrees:oak_sapling", "moretrees:oak_leaves"),
  45. sounds = default.node_sound_leaves_defaults(),
  46. movement_speed_multiplier = default.SLOW_SPEED,
  47. on_construct = enhanced_leafdecay.make_leaf_constructor({}),
  48. on_timer = enhanced_leafdecay.make_leaf_nodetimer({tree="moretrees:oak_tree"}),
  49. })
  50. minetest.register_node("moretrees:oak_wood", {
  51. description = "Oak Planks",
  52. paramtype2 = "facedir",
  53. place_param2 = 0,
  54. tiles = {"moretrees_oak_wood.png"},
  55. groups = moretrees.get_wood_groups({wood_light = 1}),
  56. sounds = default.node_sound_wood_defaults(),
  57. })
  58. minetest.register_node("moretrees:oak_sapling", {
  59. description = "Oak Sapling\n\nWill not grow in deep caves.\nGrows acorns.",
  60. drawtype = "plantlike",
  61. --visual_scale = 1.0,
  62. tiles = {"moretrees_oak_sapling.png"},
  63. paramtype = "light",
  64. sunlight_propagates = true,
  65. walkable = false,
  66. selection_box = moretrees.sapling_selection_box,
  67. groups = moretrees.sapling_groups,
  68. sounds = default.node_sound_leaves_defaults(),
  69. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  70. on_timer = function(pos, elapsed)
  71. if mtflower.can_grow(pos) then
  72. if mtflower.try_grow(pos, "moretrees:oak_tree", "moretrees:oak_leaves", "glowstone:minerals", "glowstone:minerals") then
  73. return
  74. end
  75. end
  76. if not moretrees.can_grow(pos) then
  77. minetest.get_node_timer(pos):start(math_random(SAPLING_TIME_MIN, SAPLING_TIME_MAX))
  78. return
  79. end
  80. minetest.set_node(pos, {name='air'}) -- Remove sapling first.
  81. local path = moretrees.modpath .. "/schematics/oak.mts"
  82. minetest.place_schematic(vector.add(vector.add(pos, {x=0, y=math_random(-1, 1), z=0}), SCHEMATIC_RELP), path, "random", nil, false)
  83. trunkgen.check_trunk(pos, 3, "moretrees:oak_tree")
  84. hb4.leafscatter.remove(pos, SCHEMATIC_MINP, SCHEMATIC_MAXP, "moretrees:oak_leaves", math_random(10, 30))
  85. hb4.leafscatter.add(pos, SCHEMATIC_MINP, SCHEMATIC_MAXP, "moretrees:oak_leaves", math_random(10, 30))
  86. snowscatter.dump_snowdust_on_tree(pos, SCHEMATIC_MINP, SCHEMATIC_MAXP)
  87. ambiance.spawn_sound_beacon_inside_area("soundbeacon:trees", pos, SCHEMATIC_MINP, SCHEMATIC_MAXP, 40, 3)
  88. fruitscatter.scatter_fruit_under_leaves(
  89. pos,
  90. "moretrees:oak_leaves",
  91. "moretrees:oak_acorn",
  92. SCHEMATIC_MINP,
  93. SCHEMATIC_MAXP,
  94. math_random(6, 10)
  95. )
  96. end,
  97. on_construct = function(pos)
  98. minetest.get_node_timer(pos):start(math_random(SAPLING_TIME_MIN, SAPLING_TIME_MAX))
  99. end,
  100. on_place = function(itemstack, placer, pointed_thing)
  101. itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
  102. "moretrees:oak_sapling", SCHEMATIC_MINP, SCHEMATIC_MAXP, 4)
  103. return itemstack
  104. end,
  105. })
  106. minetest.register_node("moretrees:oak_acorn", {
  107. description = "Acorn",
  108. drawtype = "plantlike",
  109. visual_scale = 0.8,
  110. tiles = {"moretrees_acorn.png"},
  111. inventory_image = "moretrees_acorn.png",
  112. paramtype = "light",
  113. sunlight_propagates = true,
  114. walkable = false,
  115. selection_box = {
  116. type = "fixed",
  117. fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2},
  118. },
  119. -- Nuts do not rot.
  120. groups = {fleshy=3, dig_immediate=3, flammable=2, leafdecay=3, leafdecay_drop=1},
  121. sounds = default.node_sound_defaults(),
  122. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  123. on_construct = enhanced_leafdecay.make_leaf_constructor({}),
  124. on_timer = enhanced_leafdecay.make_leaf_nodetimer({tree="moretrees:oak_tree"}),
  125. after_dig_node = hb4.fruitregrow.after_dig_node(),
  126. after_place_node = hb4.fruitregrow.after_place_node(),
  127. on_finish_collapse = hb4.fruitregrow.on_finish_collapse(),
  128. })
  129. minetest.register_craftitem("moretrees:acorn_muffin_batter", {
  130. description = "Acorn Muffin batter",
  131. inventory_image = "moretrees_acorn_muffin_batter.png",
  132. groups = {foodrot=1},
  133. })
  134. minetest.register_craftitem("moretrees:acorn_muffin", {
  135. description = "Acorn Muffin",
  136. inventory_image = "moretrees_acorn_muffin.png",
  137. on_use = minetest.item_eat(4),
  138. groups = {foodrot=1},
  139. })
  140. minetest.register_craft({
  141. type = "shapeless",
  142. output = "moretrees:acorn_muffin_batter",
  143. recipe = {
  144. "moretrees:oak_acorn",
  145. "moretrees:oak_acorn",
  146. "moretrees:oak_acorn",
  147. "moretrees:oak_acorn",
  148. "moretrees:coconut_milk",
  149. },
  150. replacements = {
  151. { "moretrees:coconut_milk", "vessels:drinking_glass" },
  152. },
  153. })
  154. minetest.register_craft({
  155. type = "cooking",
  156. output = "moretrees:acorn_muffin 4",
  157. recipe = "moretrees:acorn_muffin_batter",
  158. })
  159. minetest.register_craft({
  160. output = 'moretrees:oak_wood 4',
  161. recipe = {
  162. {'moretrees:oak_tree'},
  163. }
  164. })
  165. minetest.register_craft({
  166. output = "default:fence_wood 4",
  167. recipe = {
  168. {"moretrees:oak_wood", 'group:stick', "moretrees:oak_wood"},
  169. {"moretrees:oak_wood", 'group:stick', "moretrees:oak_wood"},
  170. }
  171. })
  172. minetest.register_craft({
  173. output = "doors:gate_wood_closed",
  174. recipe = {
  175. {"group:stick", "moretrees:oak_wood", "group:stick"},
  176. {"group:stick", "moretrees:oak_wood", "group:stick"}
  177. }
  178. })
  179. stairs.register_stair_and_slab(
  180. "oak",
  181. "moretrees:oak_wood",
  182. moretrees.stair_groups,
  183. {"moretrees_oak_wood.png"},
  184. "Oak Plank",
  185. default.node_sound_wood_defaults()
  186. )