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.

101 lines
2.8KB

  1. -- Code of rubber tree by PilzAdam
  2. local S = technic.worldgen.gettext
  3. minetest.register_node(":moretrees:rubber_tree_sapling", {
  4. description = S("Rubber Tree Sapling"),
  5. drawtype = "plantlike",
  6. tiles = {"technic_rubber_sapling.png"},
  7. inventory_image = "technic_rubber_sapling.png",
  8. wield_image = "technic_rubber_sapling.png",
  9. paramtype = "light",
  10. walkable = false,
  11. groups = {dig_immediate=3, flammable=2, sapling=1},
  12. sounds = default.node_sound_defaults(),
  13. })
  14. minetest.register_craft({
  15. type = "fuel",
  16. recipe = "moretrees:rubber_tree_sapling",
  17. burntime = 10
  18. })
  19. minetest.register_node(":moretrees:rubber_tree_trunk", {
  20. description = S("Rubber Tree"),
  21. tiles = {"default_tree_top.png", "default_tree_top.png",
  22. "technic_rubber_tree_full.png"},
  23. groups = {tree=1, snappy=1, choppy=2, oddly_breakable_by_hand=1,
  24. flammable=2},
  25. sounds = default.node_sound_wood_defaults(),
  26. })
  27. minetest.register_node(":moretrees:rubber_tree_trunk_empty", {
  28. description = S("Rubber Tree"),
  29. tiles = {"default_tree_top.png", "default_tree_top.png",
  30. "technic_rubber_tree_empty.png"},
  31. groups = {tree=1, snappy=1, choppy=2, oddly_breakable_by_hand=1,
  32. flammable=2, not_in_creative_inventory=1},
  33. sounds = default.node_sound_wood_defaults(),
  34. })
  35. minetest.register_node(":moretrees:rubber_tree_leaves", {
  36. drawtype = "allfaces_optional",
  37. description = S("Rubber Tree Leaves"),
  38. tiles = {"technic_rubber_leaves.png"},
  39. paramtype = "light",
  40. groups = {snappy=3, leafdecay=3, flammable=2, leaves=1},
  41. drop = {
  42. max_items = 1,
  43. items = {{
  44. items = {"moretrees:rubber_tree_sapling"},
  45. rarity = 20,
  46. },
  47. {
  48. items = {"moretrees:rubber_tree_leaves"},
  49. }
  50. }
  51. },
  52. sounds = default.node_sound_leaves_defaults(),
  53. })
  54. technic.rubber_tree_model={
  55. axiom = "FFFFA",
  56. rules_a = "[&FFBFA]////[&BFFFA]////[&FBFFA]",
  57. rules_b = "[&FFA]////[&FFA]////[&FFA]",
  58. trunk = "moretrees:rubber_tree_trunk",
  59. leaves = "moretrees:rubber_tree_leaves",
  60. angle = 35,
  61. iterations = 3,
  62. random_level = 1,
  63. trunk_type = "double",
  64. thin_branches = true
  65. }
  66. minetest.register_abm({
  67. nodenames = {"moretrees:rubber_tree_sapling"},
  68. label = "Worldgen: grow rubber tree sapling",
  69. interval = 60,
  70. chance = 20,
  71. action = function(pos, node)
  72. minetest.remove_node(pos)
  73. minetest.spawn_tree(pos, technic.rubber_tree_model)
  74. end
  75. })
  76. if technic.config:get_bool("enable_rubber_tree_generation") then
  77. minetest.register_on_generated(function(minp, maxp, blockseed)
  78. if math.random(1, 100) > 5 then
  79. return
  80. end
  81. local tmp = {
  82. x = (maxp.x - minp.x) / 2 + minp.x,
  83. y = (maxp.y - minp.y) / 2 + minp.y,
  84. z = (maxp.z - minp.z) / 2 + minp.z}
  85. local pos = minetest.find_node_near(tmp, maxp.x - minp.x,
  86. {"default:dirt_with_grass"})
  87. if pos ~= nil then
  88. minetest.spawn_tree({x=pos.x, y=pos.y+1, z=pos.z}, technic.rubber_tree_model)
  89. end
  90. end)
  91. end