init.lua 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. snow_bricks = snow_bricks or {}
  2. snow_bricks.modpath = minetest.get_modpath("snow_bricks")
  3. -- Localize for performance.
  4. local math_random = math.random
  5. minetest.register_node("snow_bricks:snow_brick", {
  6. description = "Snow Brick",
  7. tiles = {"snow_bricks_snow_brick.png"},
  8. paramtype2 = "facedir",
  9. place_param2 = 0,
  10. groups = utility.dig_groups("brick", {puts_out_fire = 1, melts = 1, cold = 1}),
  11. is_ground_content = false,
  12. _melts_to = "default:water_flowing",
  13. sounds = default.node_sound_stone_defaults({
  14. footstep = {name = "default_snow_footstep", gain = 0.15}
  15. }),
  16. on_construct = function(pos)
  17. if rc.ice_melts_at_pos(pos) then
  18. minetest.get_node_timer(pos):start(math_random(ice.minmax_time()))
  19. end
  20. end,
  21. on_timer = function(pos, elapsed)
  22. if rc.ice_melts_at_pos(pos) then
  23. -- If in nether, then water's constructor will convert again to fire.
  24. minetest.add_node(pos, {name="default:water_flowing"})
  25. end
  26. end,
  27. })
  28. minetest.register_node("snow_bricks:ice_brick", {
  29. description = "Ice Brick",
  30. tiles = {"snow_bricks_ice_brick.png"},
  31. paramtype2 = "facedir",
  32. place_param2 = 0,
  33. groups = utility.dig_groups("brick", {puts_out_fire = 1, melts = 1, cold = 1}),
  34. is_ground_content = false,
  35. _melts_to = "default:water_flowing",
  36. sounds = default.node_sound_stone_defaults({
  37. footstep = {name = "default_glass_footstep", gain = 0.35}
  38. }),
  39. on_construct = function(pos)
  40. if rc.ice_melts_at_pos(pos) then
  41. minetest.get_node_timer(pos):start(math_random(ice.minmax_time()))
  42. end
  43. end,
  44. on_timer = function(pos, elapsed)
  45. if rc.ice_melts_at_pos(pos) then
  46. -- If in nether, then water's constructor will convert again to fire.
  47. minetest.add_node(pos, {name="default:water_flowing"})
  48. end
  49. end,
  50. })
  51. minetest.register_craft({
  52. output = "snow_bricks:snow_brick 4",
  53. recipe = {
  54. {"default:snowblock", "default:snowblock"},
  55. {"default:snowblock", "default:snowblock"},
  56. }
  57. })
  58. minetest.register_craft({
  59. output = "snow_bricks:ice_brick 4",
  60. recipe = {
  61. {"default:ice", "default:ice"},
  62. {"default:ice", "default:ice"},
  63. }
  64. })
  65. minetest.register_craft({
  66. output = "snow_bricks:snow_brick",
  67. recipe = {
  68. {"default:snow", "default:snow", "default:snow"},
  69. {"default:snow", "snow_bricks:ice_brick", "default:snow"},
  70. {"default:snow", "default:snow", "default:snow"},
  71. }
  72. })
  73. stairs.register_stair_and_slab(
  74. "snow_brick",
  75. "snow_bricks:snow_brick",
  76. {cracky = 2, puts_out_fire = 1},
  77. {"snow_bricks_snow_brick.png"},
  78. "Snow Brick",
  79. default.node_sound_stone_defaults({footstep = {name = "default_snow_footstep", gain = 0.15}})
  80. )
  81. stairs.register_stair_and_slab(
  82. "ice_brick",
  83. "snow_bricks:ice_brick",
  84. {cracky = 2, puts_out_fire = 1},
  85. {"snow_bricks_ice_brick.png"},
  86. "Ice Brick",
  87. default.node_sound_stone_defaults({footstep = {name = "default_glass_footstep", gain = 0.35}})
  88. )