oak.lua 6.4 KB

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