crystal.lua 7.7 KB

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