Skip to content

Commit d90c17e

Browse files
MineClone smoker and blast furnace support (#85)
1 parent 4f55610 commit d90c17e

File tree

1 file changed

+252
-8
lines changed

1 file changed

+252
-8
lines changed

mcl_furnaces.lua

Lines changed: 252 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
11

22
local old_furnace = table.copy(minetest.registered_nodes["mcl_furnaces:furnace"])
3+
local old_blast_furnace = table.copy(minetest.registered_nodes["mcl_blast_furnace:blast_furnace"])
4+
local old_smoker = table.copy(minetest.registered_nodes["mcl_smoker:smoker"])
35

46
local tube_entry = "^pipeworks_tube_connection_stony.png"
57

6-
local groups = old_furnace.groups
7-
groups["tubedevice"] = 1
8-
groups["tubedevice_receiver"] = 1
9-
local groups_active = table.copy(groups)
10-
groups_active["not_in_creative_inventory"] = 1
8+
-- groups
9+
local furnace_groups = old_furnace.groups
10+
furnace_groups["tubedevice"] = 1
11+
furnace_groups["tubedevice_receiver"] = 1
12+
local furnace_groups_active = table.copy(furnace_groups)
13+
furnace_groups_active["not_in_creative_inventory"] = 1
14+
15+
local blast_furnace_groups = old_blast_furnace.groups
16+
blast_furnace_groups["tubedevice"] = 1
17+
blast_furnace_groups["tubedevice_receiver"] = 1
18+
local blast_furnace_groups_active = table.copy(blast_furnace_groups)
19+
blast_furnace_groups_active["not_in_creative_inventory"] = 1
20+
21+
local smoker_groups = old_smoker.groups
22+
smoker_groups["tubedevice"] = 1
23+
smoker_groups["tubedevice_receiver"] = 1
24+
local smoker_groups_active = table.copy(smoker_groups)
25+
smoker_groups_active["not_in_creative_inventory"] = 1
26+
1127

1228
-- a hack to give the exp to fake players it's be dropped instead added to (fake) player inv
1329
local function give_xp(pos, player)
1430
local meta = minetest.get_meta(pos)
15-
local dir = vector.divide(minetest.facedir_to_dir(minetest.get_node(pos).param2),-1.95)
31+
local dir = vector.divide(minetest.facedir_to_dir(minetest.get_node(pos).param2), -1.95)
1632
local xp = meta:get_int("xp")
1733
if xp > 0 then
1834
mcl_experience.throw_xp(vector.add(pos, dir), xp)
@@ -31,7 +47,7 @@ override.tiles = {
3147
"default_furnace_front.png"
3248
}
3349

34-
override.groups = groups
50+
override.groups = furnace_groups
3551

3652
override.tube = {
3753
insert_object = function(pos, node, stack, direction)
@@ -97,7 +113,7 @@ override_active.tiles = {
97113
"default_furnace_front_active.png",
98114
}
99115

100-
override_active.groups = groups_active
116+
override_active.groups = furnace_groups_active
101117

102118
override_active.tube = {
103119
insert_object = function(pos,node,stack,direction)
@@ -127,6 +143,234 @@ override_active.tube = {
127143
}
128144

129145

146+
--blast furnace
147+
148+
local override_blast_furnace = {}
149+
150+
override_blast_furnace.tiles = {
151+
"blast_furnace_top.png"..tube_entry,
152+
"blast_furnace_top.png"..tube_entry,
153+
"blast_furnace_side.png"..tube_entry,
154+
"blast_furnace_side.png"..tube_entry,
155+
"blast_furnace_side.png"..tube_entry,
156+
"blast_furnace_front.png"
157+
}
158+
159+
override_blast_furnace.groups = blast_furnace_groups
160+
161+
override_blast_furnace.tube = {
162+
insert_object = function(pos, node, stack, direction)
163+
local meta = minetest.get_meta(pos)
164+
local inv = meta:get_inventory()
165+
local timer = minetest.get_node_timer(pos)
166+
if not timer:is_started() then
167+
timer:start(1.0)
168+
end
169+
if direction.y == 1 then
170+
return inv:add_item("fuel", stack)
171+
else
172+
return inv:add_item("src", stack)
173+
end
174+
end,
175+
can_insert = function(pos,node,stack,direction)
176+
local meta = minetest.get_meta(pos)
177+
local inv = meta:get_inventory()
178+
if direction.y == 1 then
179+
return inv:room_for_item("fuel", stack)
180+
else
181+
if meta:get_int("split_material_stacks") == 1 then
182+
stack = stack:peek_item(1)
183+
end
184+
return inv:room_for_item("src", stack)
185+
end
186+
end,
187+
input_inventory = "dst",
188+
connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
189+
}
190+
191+
override_blast_furnace.after_place_node = function(pos, placer, itemstack, pointed_thing)
192+
pipeworks.after_place(pos, placer, itemstack, pointed_thing)
193+
end
194+
195+
override_blast_furnace.after_dig_node = function(pos, oldnode, oldmetadata, digger)
196+
old_blast_furnace.after_dig_node(pos, oldnode, oldmetadata, digger)
197+
pipeworks.after_dig(pos)
198+
end
199+
200+
override_blast_furnace.on_metadata_inventory_take = function(pos, listname, index, stack, player)
201+
-- Award smelting achievements
202+
if listname == "dst" then
203+
if stack:get_name() == "mcl_core:iron_ingot" then
204+
awards.unlock(player:get_player_name(), "mcl:acquireIron")
205+
end
206+
give_xp(pos, player)
207+
end
208+
end
209+
210+
override_blast_furnace.on_rotate = pipeworks.on_rotate
211+
212+
213+
local override_blast_active = table.copy(override)
214+
215+
override_blast_active.tiles = {
216+
"blast_furnace_top.png"..tube_entry,
217+
"blast_furnace_top.png"..tube_entry,
218+
"blast_furnace_side.png"..tube_entry,
219+
"blast_furnace_side.png"..tube_entry,
220+
"blast_furnace_side.png"..tube_entry,
221+
{
222+
name = "blast_furnace_front_on.png",
223+
animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 48 }
224+
},
225+
}
226+
227+
override_blast_active.groups = blast_furnace_groups_active
228+
229+
override_blast_active.tube = {
230+
insert_object = function(pos,node,stack,direction)
231+
local meta = minetest.get_meta(pos)
232+
local inv = meta:get_inventory()
233+
local timer = minetest.get_node_timer(pos)
234+
if not timer:is_started() then
235+
timer:start(1.0)
236+
end
237+
if direction.y == 1 then
238+
return inv:add_item("fuel", stack)
239+
else
240+
return inv:add_item("src", stack)
241+
end
242+
end,
243+
can_insert = function(pos, node, stack, direction)
244+
local meta = minetest.get_meta(pos)
245+
local inv = meta:get_inventory()
246+
if direction.y == 1 then
247+
return inv:room_for_item("fuel", stack)
248+
else
249+
return inv:room_for_item("src", stack)
250+
end
251+
end,
252+
input_inventory = "dst",
253+
connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
254+
}
255+
256+
257+
-- smoker
258+
259+
local override_smoker = {}
260+
261+
override_smoker.tiles = {
262+
"smoker_top.png"..tube_entry,
263+
"smoker_bottom.png"..tube_entry,
264+
"smoker_side.png"..tube_entry,
265+
"smoker_side.png"..tube_entry,
266+
"smoker_side.png"..tube_entry,
267+
"smoker_front.png"
268+
}
269+
270+
override_smoker.groups = smoker_groups
271+
272+
override_smoker.tube = {
273+
insert_object = function(pos, node, stack, direction)
274+
local meta = minetest.get_meta(pos)
275+
local inv = meta:get_inventory()
276+
local timer = minetest.get_node_timer(pos)
277+
if not timer:is_started() then
278+
timer:start(1.0)
279+
end
280+
if direction.y == 1 then
281+
return inv:add_item("fuel", stack)
282+
else
283+
return inv:add_item("src", stack)
284+
end
285+
end,
286+
can_insert = function(pos,node,stack,direction)
287+
local meta = minetest.get_meta(pos)
288+
local inv = meta:get_inventory()
289+
if direction.y == 1 then
290+
return inv:room_for_item("fuel", stack)
291+
else
292+
if meta:get_int("split_material_stacks") == 1 then
293+
stack = stack:peek_item(1)
294+
end
295+
return inv:room_for_item("src", stack)
296+
end
297+
end,
298+
input_inventory = "dst",
299+
connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
300+
}
301+
302+
override_smoker.after_place_node = function(pos, placer, itemstack, pointed_thing)
303+
pipeworks.after_place(pos, placer, itemstack, pointed_thing)
304+
end
305+
306+
override_smoker.after_dig_node = function(pos, oldnode, oldmetadata, digger)
307+
old_smoker.after_dig_node(pos, oldnode, oldmetadata, digger)
308+
pipeworks.after_dig(pos)
309+
end
310+
311+
override_smoker.on_metadata_inventory_take = function(pos, listname, index, stack, player)
312+
-- Award fish achievements
313+
if listname == "dst" then
314+
if stack:get_name() == "mcl_fishing:fish_cooked" then
315+
awards.unlock(player:get_player_name(), "mcl:cookFish")
316+
end
317+
give_xp(pos, player)
318+
end
319+
end
320+
321+
override_smoker.on_rotate = pipeworks.on_rotate
322+
323+
324+
local override_smoker_active = table.copy(override)
325+
326+
override_smoker_active.tiles = {
327+
"smoker_top.png"..tube_entry,
328+
"smoker_bottom.png"..tube_entry,
329+
"smoker_side.png"..tube_entry,
330+
"smoker_side.png"..tube_entry,
331+
"smoker_side.png"..tube_entry,
332+
{
333+
name = "smoker_front_on.png",
334+
animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 48 }
335+
},
336+
}
337+
338+
override_smoker_active.groups = smoker_groups_active
339+
340+
override_smoker_active.tube = {
341+
insert_object = function(pos,node,stack,direction)
342+
local meta = minetest.get_meta(pos)
343+
local inv = meta:get_inventory()
344+
local timer = minetest.get_node_timer(pos)
345+
if not timer:is_started() then
346+
timer:start(1.0)
347+
end
348+
if direction.y == 1 then
349+
return inv:add_item("fuel", stack)
350+
else
351+
return inv:add_item("src", stack)
352+
end
353+
end,
354+
can_insert = function(pos, node, stack, direction)
355+
local meta = minetest.get_meta(pos)
356+
local inv = meta:get_inventory()
357+
if direction.y == 1 then
358+
return inv:room_for_item("fuel", stack)
359+
else
360+
return inv:room_for_item("src", stack)
361+
end
362+
end,
363+
input_inventory = "dst",
364+
connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
365+
}
366+
367+
130368
-- override
131369
minetest.override_item("mcl_furnaces:furnace", override)
132370
minetest.override_item("mcl_furnaces:furnace_active", override_active)
371+
372+
minetest.override_item("mcl_blast_furnace:blast_furnace", override_blast_furnace)
373+
minetest.override_item("mcl_blast_furnace:blast_furnace_active", override_blast_active)
374+
375+
minetest.override_item("mcl_smoker:smoker", override_smoker)
376+
minetest.override_item("mcl_smoker:smoker_active", override_smoker_active)

0 commit comments

Comments
 (0)