diff --git a/mods/ITEMS/mcl_campfires/init.lua b/mods/ITEMS/mcl_campfires/init.lua index e51ec9f54..a3ed657f6 100644 --- a/mods/ITEMS/mcl_campfires/init.lua +++ b/mods/ITEMS/mcl_campfires/init.lua @@ -3,13 +3,84 @@ -- |||||||||||||||||||||||||||||||| -- TO-DO: --- * Add Smoke Particles -- * Add Spark Particles -- * Add Cooking Meat -- * Add Working Sounds local S = minetest.get_translator(minetest.get_current_modname()) + +mcl_campfires = {} + +function mcl_campfires.register_smoke(pos) + local meta = minetest.get_meta(pos) + + -- delete existing spawner + local existing_spawner = meta:get_int("smoke_particlespawner") + if existing_spawner ~= 0 then + minetest.delete_particlespawner(existing_spawner) + end + + -- velocity: 0.5 + -- acceleration: 0.1 + ------------------------ + -- 7 seconds ~= 10 nodes + -- 12 seconds ~= 20 nodes + + local time = 7 + if minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z}).name == "mcl_farming:hay_block" then + time = 12 + end + + -- create new spawner + local smokeID = minetest.add_particlespawner({ + time = 0, + ammount = 0.2, + collisiondetection = true, + texture = "mcl_campfires_smoke_4.png", + texpool = { + { name = "mcl_campfires_smoke_0.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_2.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_3.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_4.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_5.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_7.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_8.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_9.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_1.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_10.png", alpha_tween = {1, 0}}, + { name = "mcl_campfires_smoke_11.png", alpha_tween = {1, 0}}, + }, + + minpos = {x=pos.x - 0.25, y=pos.y + 0.25, z=pos.z - 0.25}, + maxpos = {x=pos.x + 0.25, y=pos.y + 0.25, z=pos.z + 0.25}, + minvel = {x=0, y=1, z=0}, + maxvel = {x=0, y=1, z=0}, + minacc = {x=0, y=0.1, z=0}, + maxacc = {x=0, y=0.1, z=0}, + minexptime = time, + maxexptime = time, + minsize = 12, + maxsize = 12, + }) + + -- save the id in meta + meta:set_int("smoke_particlespawner", smokeID) + + return smokeID +end + +function mcl_campfires.remove_smoke(pos) + local meta = minetest.get_meta(pos) + local smokeID = meta:get_int("smoke_particlespawner") + + -- end function if smoke doesnt exist + if not smokeID then return 0 end + + return minetest.delete_particlespawner(smokeID) +end + + local campfires = { { name = "Campfire", lightlevel = 15, techname = "campfire", damage = 1, drops = "mcl_core:charcoal_lump 2" }, { name = "Soul Campfire", lightlevel = 10, techname = "soul_campfire", damage = 2, drops = "mcl_blackstone:soul_soil" }, @@ -76,11 +147,14 @@ for _, campfire in pairs(campfires) do groups = { handy=1, axey=1, material_wood=1, campfire=1, lit_campfire=1 }, paramtype = "light", paramtype2 = "facedir", + on_construct = mcl_campfires.register_smoke, + on_destruct = mcl_campfires.remove_smoke, on_rightclick = function (pos, node, player, itemstack, pointed_thing) if player:get_wielded_item():get_name():find("shovel") then node.name = "mcl_campfires:" .. campfire.techname minetest.set_node(pos, node) minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true) + mcl_campfires.remove_smoke(pos) end end, drop = campfire.drops, diff --git a/mods/ITEMS/mcl_campfires/textures/desktop.ini b/mods/ITEMS/mcl_campfires/textures/desktop.ini new file mode 100644 index 000000000..96ab76a82 --- /dev/null +++ b/mods/ITEMS/mcl_campfires/textures/desktop.ini @@ -0,0 +1,2 @@ +[LocalizedFileNames] +big_smoke_4.png=@big_smoke_4.png,0 diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_0.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_0.png new file mode 100644 index 000000000..454a97d7a Binary files /dev/null and b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_0.png differ diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_1.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_1.png new file mode 100644 index 000000000..93c7491f6 Binary files /dev/null and b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_1.png differ diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_10.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_10.png new file mode 100644 index 000000000..0d8f732ce Binary files /dev/null and b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_10.png differ diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_11.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_11.png new file mode 100644 index 000000000..9709d5aaf Binary files /dev/null and b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_11.png differ diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_2.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_2.png new file mode 100644 index 000000000..2bf0d0c02 Binary files /dev/null and b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_2.png differ diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_3.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_3.png new file mode 100644 index 000000000..aaa332d3d Binary files /dev/null and b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_3.png differ diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_4.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_4.png new file mode 100644 index 000000000..5acb2551c Binary files /dev/null and b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_4.png differ diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_5.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_5.png new file mode 100644 index 000000000..9db190804 Binary files /dev/null and b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_5.png differ diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_6.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_6.png new file mode 100644 index 000000000..dfb9023a1 Binary files /dev/null and b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_6.png differ diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_7.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_7.png new file mode 100644 index 000000000..1b1fb466b Binary files /dev/null and b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_7.png differ diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_8.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_8.png new file mode 100644 index 000000000..903f3571a Binary files /dev/null and b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_8.png differ diff --git a/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_9.png b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_9.png new file mode 100644 index 000000000..f12057b47 Binary files /dev/null and b/mods/ITEMS/mcl_campfires/textures/mcl_campfires_smoke_9.png differ diff --git a/mods/ITEMS/mcl_farming/wheat.lua b/mods/ITEMS/mcl_farming/wheat.lua index a254ed36c..429cbed1d 100644 --- a/mods/ITEMS/mcl_farming/wheat.lua +++ b/mods/ITEMS/mcl_farming/wheat.lua @@ -148,6 +148,17 @@ if mod_screwdriver then on_rotate = screwdriver.rotate_3way end +local function update_campfires(pos) + local pos_above = {x = pos.x, y = pos.y + 1, z = pos.z} + local node_above = minetest.get_node(pos_above) + + minetest.chat_send_all(node_above.name) + if node_above.name == "mcl_campfires:campfire_lit" or node_above.name == "mcl_campfires:soul_campfire_lit" then + mcl_campfires.register_smoke(pos_above) + minetest.chat_send_all("success") + end +end + minetest.register_node("mcl_farming:hay_block", { description = S("Hay Bale"), _doc_items_longdesc = S("Hay bales are decorative blocks made from wheat."), @@ -156,6 +167,8 @@ minetest.register_node("mcl_farming:hay_block", { stack_max = 64, paramtype2 = "facedir", on_place = mcl_util.rotate_axis, + on_construct = update_campfires, + after_destruct = update_campfires, groups = { handy = 1, hoey = 1, building_block = 1, fall_damage_add_percent = -80, flammable = 2, fire_encouragement = 60, fire_flammability = 20,