acaciatree.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. basictrees = basictrees or {}
  2. local SAPLING_TIME_MIN = 60*15
  3. local SAPLING_TIME_MAX = 60*30
  4. local SAPLING_CHANCE = 25
  5. local SCHEMATIC_MINP = {x=-4, y=1, z=-4}
  6. local SCHEMATIC_MAXP = {x=4, y=6, z=4}
  7. local SCHEMATIC_RELP = {x=-4, y=-1, z=-4}
  8. -- Localize for performance.
  9. local math_random = math.random
  10. minetest.register_node("basictrees:acacia_trunk", {
  11. drawtype = "nodebox",
  12. paramtype = "light",
  13. node_box = {
  14. type = "fixed",
  15. fixed = basictrees.trunk_nodebox,
  16. },
  17. description = "Acacia Tree",
  18. tiles = {"default_acacia_tree_top.png", "default_acacia_tree_top.png", "default_acacia_tree.png"},
  19. paramtype2 = "facedir",
  20. groups = basictrees.tree_groups,
  21. sounds = default.node_sound_wood_defaults(),
  22. on_place = minetest.rotate_node,
  23. movement_speed_multiplier = default.NORM_SPEED,
  24. on_destruct = enhanced_leafdecay.make_tree_destructor({
  25. leaves = {
  26. "basictrees:acacia_leaves",
  27. "group:dry_leaves",
  28. },
  29. }),
  30. })
  31. minetest.register_node("basictrees:acacia_wood", {
  32. description = "Acacia Wood Planks",
  33. paramtype2 = "facedir",
  34. place_param2 = 0,
  35. tiles = {"default_acacia_wood.png"},
  36. groups = basictrees.get_wood_groups({wood_light = 1}),
  37. sounds = default.node_sound_wood_defaults(),
  38. })
  39. minetest.register_node("basictrees:acacia_leaves", {
  40. description = "Acacia Tree Leaves",
  41. drawtype = "allfaces_optional",
  42. visual_scale = 1.3,
  43. tiles = {"default_acacia_leaves.png"},
  44. waving = 1,
  45. paramtype = "light",
  46. groups = basictrees.leaves_groups,
  47. drop = basictrees.get_leafdrop_table(SAPLING_CHANCE, "basictrees:acacia_sapling", "basictrees:acacia_leaves"),
  48. sounds = default.node_sound_leaves_defaults(),
  49. movement_speed_multiplier = default.SLOW_SPEED,
  50. on_construct = enhanced_leafdecay.make_leaf_constructor({}),
  51. on_timer = enhanced_leafdecay.make_leaf_nodetimer({tree="basictrees:acacia_trunk"}),
  52. })
  53. minetest.register_node("basictrees:acacia_sapling", {
  54. description = "Acacia Tree Sapling\n\nWill not grow in deep caves.",
  55. drawtype = "plantlike",
  56. --visual_scale = 1.0,
  57. tiles = {"default_acacia_sapling.png"},
  58. inventory_image = "default_acacia_sapling.png",
  59. wield_image = "default_acacia_sapling.png",
  60. paramtype = "light",
  61. sunlight_propagates = true,
  62. walkable = false,
  63. selection_box = basictrees.sapling_selection_box,
  64. groups = basictrees.sapling_groups,
  65. sounds = default.node_sound_leaves_defaults(),
  66. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  67. on_timer = function(pos)
  68. if mtflower.can_grow(pos) then
  69. if mtflower.try_grow(pos, "basictrees:acacia_trunk", "basictrees:acacia_leaves", "glowstone:minerals", "glowstone:minerals") then
  70. return
  71. end
  72. end
  73. if not basictrees.can_grow(pos) then
  74. minetest.get_node_timer(pos):start(math_random(SAPLING_TIME_MIN, SAPLING_TIME_MAX))
  75. return
  76. end
  77. local path = basictrees.modpath .. "/schematics/acacia_tree_from_sapling.mts"
  78. minetest.place_schematic(vector.add(pos, SCHEMATIC_RELP), path, "random", nil, false)
  79. snowscatter.dump_snowdust_on_tree(pos, SCHEMATIC_MINP, SCHEMATIC_MAXP)
  80. serveressentials.fix_acacia_tree(vector.add(pos, SCHEMATIC_MINP), vector.add(pos, SCHEMATIC_MAXP))
  81. ambiance.spawn_sound_beacon_inside_area("soundbeacon:trees", pos, SCHEMATIC_MINP, SCHEMATIC_MAXP, 40, 3)
  82. end,
  83. on_construct = function(pos)
  84. minetest.get_node_timer(pos):start(math_random(SAPLING_TIME_MIN, SAPLING_TIME_MAX))
  85. end,
  86. on_place = function(itemstack, placer, pointed_thing)
  87. itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
  88. "basictrees:acacia_sapling", SCHEMATIC_MINP, SCHEMATIC_MAXP, 4)
  89. return itemstack
  90. end,
  91. })
  92. minetest.register_craft({
  93. output = 'basictrees:acacia_wood 4',
  94. recipe = {
  95. {'basictrees:acacia_trunk'},
  96. }
  97. })
  98. minetest.register_alias("default:acacia_tree", "basictrees:acacia_trunk")
  99. minetest.register_alias("default:acacia_leaves", "basictrees:acacia_leaves")
  100. minetest.register_alias("default:acacia_sapling", "basictrees:acacia_sapling")
  101. minetest.register_alias("default:acacia_wood", "basictrees:acacia_wood")