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