crystal.lua 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. local S = ethereal.intllib
  2. -- Crystal Spike (Hurts if you touch it - thanks to ZonerDarkRevention for his DokuCraft DeviantArt crystal texture)
  3. minetest.register_node("ethereal:crystal_spike", {
  4. description = S("Crystal Spike"),
  5. drawtype = "plantlike",
  6. tiles = { "crystal_spike.png" },
  7. inventory_image = "crystal_spike.png",
  8. wield_image = "crystal_spike.png",
  9. paramtype = "light",
  10. light_source = 7,
  11. sunlight_propagates = true,
  12. walkable = true,
  13. damage_per_second = 1,
  14. groups = {cracky = 1, falling_node = 1, puts_out_fire = 1, cools_lava = 1},
  15. sounds = default.node_sound_glass_defaults(),
  16. selection_box = {
  17. type = "fixed",
  18. fixed = {-5 / 16, -0.5, -5 / 16, 5 / 16, 0, 5 / 16},
  19. },
  20. node_box = {
  21. type = "fixed",
  22. fixed = {-5 / 16, -0.5, -5 / 16, 5 / 16, 0, 5 / 16},
  23. },
  24. })
  25. -- Crystal Ingot
  26. minetest.register_craftitem("ethereal:crystal_ingot", {
  27. description = S("Crystal Ingot"),
  28. inventory_image = "crystal_ingot.png",
  29. wield_image = "crystal_ingot.png",
  30. })
  31. if minetest.get_modpath("builtin_item") then
  32. minetest.override_item("ethereal:crystal_spike", {
  33. dropped_step = function(self, pos, dtime)
  34. self.ctimer = (self.ctimer or 0) + dtime
  35. if self.ctimer < 5.0 then return end
  36. self.ctimer = 0
  37. if self.node_inside
  38. and self.node_inside.name ~= "default:water_source" then
  39. return
  40. end
  41. local objs = core.get_objects_inside_radius(pos, 0.8)
  42. if not objs or #objs ~= 2 then return end
  43. local crystal, mese, ent = nil, nil, nil
  44. for k, obj in pairs(objs) do
  45. ent = obj:get_luaentity()
  46. if ent and ent.name == "__builtin:item" then
  47. if ent.itemstring == "default:mese_crystal 2"
  48. and not mese then
  49. mese = obj
  50. elseif ent.itemstring == "ethereal:crystal_spike 2"
  51. and not crystal then
  52. crystal = obj
  53. end
  54. end
  55. end
  56. if mese and crystal then
  57. mese:remove()
  58. crystal:remove()
  59. core.add_item(pos, "ethereal:crystal_ingot")
  60. return false
  61. end
  62. end
  63. })
  64. end
  65. minetest.register_craft({
  66. type = "shapeless",
  67. output = "ethereal:crystal_ingot",
  68. recipe = {
  69. "default:mese_crystal", "ethereal:crystal_spike",
  70. "ethereal:crystal_spike", "default:mese_crystal", "bucket:bucket_water"
  71. },
  72. replacements = { {"bucket:bucket_water", "bucket:bucket_empty"} }
  73. })
  74. -- Crystal Block
  75. minetest.register_node("ethereal:crystal_block", {
  76. description = S("Crystal Block"),
  77. tiles = {"crystal_block.png"},
  78. light_source = 9,
  79. is_ground_content = false,
  80. groups = {cracky = 1, level = 2, puts_out_fire = 1, cools_lava = 1},
  81. sounds = default.node_sound_glass_defaults(),
  82. })
  83. minetest.register_craft({
  84. output = "ethereal:crystal_block",
  85. recipe = {
  86. {"ethereal:crystal_ingot", "ethereal:crystal_ingot", "ethereal:crystal_ingot"},
  87. {"ethereal:crystal_ingot", "ethereal:crystal_ingot", "ethereal:crystal_ingot"},
  88. {"ethereal:crystal_ingot", "ethereal:crystal_ingot", "ethereal:crystal_ingot"},
  89. }
  90. })
  91. minetest.register_craft({
  92. output = "ethereal:crystal_ingot 9",
  93. recipe = {
  94. {"ethereal:crystal_block"},
  95. }
  96. })
  97. -- Crystal Sword (Powerful wee beastie)
  98. minetest.register_tool("ethereal:sword_crystal", {
  99. description = S("Crystal Sword"),
  100. inventory_image = "crystal_sword.png",
  101. wield_image = "crystal_sword.png",
  102. tool_capabilities = {
  103. full_punch_interval = 0.6,
  104. max_drop_level = 1,
  105. groupcaps = {
  106. snappy = {
  107. times = {[1] = 1.70, [2] = 0.70, [3] = 0.25},
  108. uses = 50,
  109. maxlevel = 3
  110. },
  111. },
  112. damage_groups = {fleshy = 10},
  113. },
  114. groups = {sword = 1},
  115. sound = {breaks = "default_tool_breaks"},
  116. })
  117. minetest.register_craft({
  118. output = "ethereal:sword_crystal",
  119. recipe = {
  120. {"ethereal:crystal_ingot"},
  121. {"ethereal:crystal_ingot"},
  122. {"default:steel_ingot"},
  123. }
  124. })
  125. -- Crystal Axe
  126. minetest.register_tool("ethereal:axe_crystal", {
  127. description = S("Crystal Axe"),
  128. inventory_image = "crystal_axe.png",
  129. wield_image = "crystal_axe.png",
  130. tool_capabilities = {
  131. full_punch_interval = 0.8,
  132. max_drop_level = 1,
  133. groupcaps = {
  134. choppy = {
  135. times = {[1] = 2.00, [2] = 0.80, [3] = 0.40},
  136. uses = 40,
  137. maxlevel = 3
  138. },
  139. },
  140. damage_groups = {fleshy = 7},
  141. },
  142. groups = {axe = 1},
  143. sound = {breaks = "default_tool_breaks"},
  144. })
  145. minetest.register_craft({
  146. output = "ethereal:axe_crystal",
  147. recipe = {
  148. {"ethereal:crystal_ingot", "ethereal:crystal_ingot"},
  149. {"ethereal:crystal_ingot", "default:steel_ingot"},
  150. {"", "default:steel_ingot"},
  151. }
  152. })
  153. minetest.register_craft({
  154. output = "ethereal:axe_crystal",
  155. recipe = {
  156. {"ethereal:crystal_ingot", "ethereal:crystal_ingot"},
  157. {"default:steel_ingot", "ethereal:crystal_ingot"},
  158. {"default:steel_ingot", ""},
  159. }
  160. })
  161. -- Crystal Pick (This will last a while)
  162. minetest.register_tool("ethereal:pick_crystal", {
  163. description = S("Crystal Pickaxe"),
  164. inventory_image = "crystal_pick.png",
  165. wield_image = "crystal_pick.png",
  166. tool_capabilities = {
  167. full_punch_interval = 0.7,
  168. max_drop_level = 3,
  169. groupcaps={
  170. cracky = {
  171. times = {[1] = 1.8, [2] = 0.8, [3] = 0.40},
  172. uses = 40,
  173. maxlevel = 3
  174. },
  175. },
  176. damage_groups = {fleshy = 6},
  177. },
  178. groups = {pickaxe = 1},
  179. sound = {breaks = "default_tool_breaks"},
  180. })
  181. minetest.register_craft({
  182. output = "ethereal:pick_crystal",
  183. recipe = {
  184. {"ethereal:crystal_ingot", "ethereal:crystal_ingot", "ethereal:crystal_ingot"},
  185. {"", "default:steel_ingot", ""},
  186. {"", "default:steel_ingot", ""},
  187. }
  188. })
  189. local old_handle_node_drops = minetest.handle_node_drops
  190. function minetest.handle_node_drops(pos, drops, digger)
  191. -- are we holding Crystal Shovel?
  192. if digger:get_wielded_item():get_name() ~= "ethereal:shovel_crystal" then
  193. return old_handle_node_drops(pos, drops, digger)
  194. end
  195. local nn = minetest.get_node(pos).name
  196. if minetest.get_item_group(nn, "crumbly") == 0 then
  197. return old_handle_node_drops(pos, drops, digger)
  198. end
  199. return old_handle_node_drops(pos, {ItemStack(nn)}, digger)
  200. end
  201. minetest.register_tool("ethereal:shovel_crystal", {
  202. description = "Crystal Shovel",
  203. inventory_image = "crystal_shovel.png",
  204. wield_image = "crystal_shovel.png^[transformR90",
  205. tool_capabilities = {
  206. full_punch_interval = 1.0,
  207. max_drop_level=1,
  208. groupcaps={
  209. crumbly = {times={[1]=1.10, [2]=0.50, [3]=0.30}, uses=30, maxlevel=3},
  210. },
  211. damage_groups = {fleshy = 4},
  212. },
  213. groups = {shovel = 1},
  214. sound = {breaks = "default_tool_breaks"},
  215. })
  216. minetest.register_craft({
  217. output = "ethereal:shovel_crystal",
  218. recipe = {
  219. {"ethereal:crystal_ingot"},
  220. {"default:steel_ingot"},
  221. {"default:steel_ingot"},
  222. }
  223. })
  224. -- Crystal Gilly Staff (replenishes air supply when used)
  225. minetest.register_tool("ethereal:crystal_gilly_staff", {
  226. description = S("Crystal Gilly Staff"),
  227. inventory_image = "crystal_gilly_staff.png",
  228. wield_image = "crystal_gilly_staff.png",
  229. on_use = function(itemstack, user, pointed_thing)
  230. if user:get_breath() < 10 then
  231. user:set_breath(10)
  232. end
  233. end,
  234. })
  235. minetest.register_craft({
  236. type = "shapeless",
  237. output = "ethereal:crystal_gilly_staff",
  238. recipe = {
  239. "ethereal:green_moss", "ethereal:gray_moss", "ethereal:fiery_moss",
  240. "ethereal:crystal_moss", "ethereal:crystal_ingot", "ethereal:mushroom_moss",
  241. "ethereal:crystal_ingot"
  242. },
  243. })
  244. -- Add [toolranks] mod support if found
  245. if minetest.get_modpath("toolranks") then
  246. -- Helper function
  247. local function add_tool(name, desc, afteruse)
  248. minetest.override_item(name, {
  249. original_description = desc,
  250. description = toolranks.create_description(desc, 0, 1),
  251. after_use = afteruse and toolranks.new_afteruse
  252. })
  253. end
  254. add_tool("ethereal:pick_crystal", "Crystal Pickaxe", true)
  255. add_tool("ethereal:axe_crystal", "Crystal Axe", true)
  256. add_tool("ethereal:shovel_crystal", "Crystal Shovel", true)
  257. add_tool("ethereal:sword_crystal", "Crystal Sword", true)
  258. end