From 23d6c3d17b0bdbe676c43e2fa433a1a5d178a11d Mon Sep 17 00:00:00 2001 From: PrairieWind Date: Wed, 7 Jun 2023 17:13:19 -0600 Subject: [PATCH] Update campfire rightclick and smothering --- mods/ITEMS/mcl_campfires/API.md | 11 ++++++----- mods/ITEMS/mcl_campfires/api.lua | 6 +++++- mods/ITEMS/mcl_campfires/init.lua | 1 - mods/ITEMS/mcl_potions/functions.lua | 17 ++++++++++++++--- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/mods/ITEMS/mcl_campfires/API.md b/mods/ITEMS/mcl_campfires/API.md index abf61c6f1..727a26daf 100644 --- a/mods/ITEMS/mcl_campfires/API.md +++ b/mods/ITEMS/mcl_campfires/API.md @@ -1,7 +1,5 @@ -MineClone 2 Campfire API -======================== -`mcl_campfires.register_campfire` ---------------------------------- +# MineClone 2 Campfire API +## `mcl_campfires.register_campfire` Used to register campfires. **Example Usage** @@ -23,4 +21,7 @@ mcl_campfires.register_campfire("mcl_campfires:campfire", { * lit_logs_texture - texture for the logs of the lit campfire. if not changed, specify mcl_campfires_log.png. * drops - what items drop when the campfire is mined. * lightlevel - the level of light the campfire emits. -* damage - amount of damage the campfire deals when the player stands on it. \ No newline at end of file +* damage - amount of damage the campfire deals when the player stands on it. + +## Cooking Items +To allow an item to be cooked on the campfire, it must first have a registered cooked variant. To allow placing the item on the campfire to be cooked, add `campfire_cookable = 1` into the item groups list. diff --git a/mods/ITEMS/mcl_campfires/api.lua b/mods/ITEMS/mcl_campfires/api.lua index 02c4aae08..a1987235f 100644 --- a/mods/ITEMS/mcl_campfires/api.lua +++ b/mods/ITEMS/mcl_campfires/api.lua @@ -223,8 +223,11 @@ function mcl_campfires.register_campfire(name, def) minetest.set_node(pos, node) minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true) end + elseif minetest.get_item_group(itemstack:get_name(), "campfire_cookable") ~= 0 then + mcl_campfires.take_item(pos, node, player, itemstack) + else + minetest.item_place_node(itemstack, player, pointed_thing) end - mcl_campfires.take_item(pos, node, player, itemstack) end, on_timer = mcl_campfires.cook_item, drop = def.drops, @@ -244,6 +247,7 @@ function mcl_campfires.register_campfire(name, def) damage_per_second = def.damage, on_blast = on_blast, after_dig_node = drop_items, + _mcl_campfires_smothered_form = name, }) end diff --git a/mods/ITEMS/mcl_campfires/init.lua b/mods/ITEMS/mcl_campfires/init.lua index 058ba50ed..cee898d0e 100644 --- a/mods/ITEMS/mcl_campfires/init.lua +++ b/mods/ITEMS/mcl_campfires/init.lua @@ -1,7 +1,6 @@ -- TO-DO: -- * Add Smoke Particles -- * Add Spark Particles --- * Add Cooking Meat -- * Add Working Sounds local modname = minetest.get_modpath(minetest.get_current_modname()) diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index de3f6df10..20608a7df 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -969,7 +969,7 @@ end function mcl_potions._extinguish_nearby_fire(pos, radius) local epos = {x=pos.x, y=pos.y+0.5, z=pos.z} local dnode = minetest.get_node({x=pos.x,y=pos.y-0.5,z=pos.z}) - if minetest.get_item_group(dnode.name, "fire") ~= 0 then + if minetest.get_item_group(dnode.name, "fire") ~= 0 or minetest.get_item_group(dnode.name, "lit_campfire") ~= 0 then epos.y = pos.y - 0.5 end local exting = false @@ -989,6 +989,11 @@ function mcl_potions._extinguish_nearby_fire(pos, radius) minetest.sound_play("fire_extinguish_flame", {pos = tpos, gain = 0.25, max_hear_distance = 16}, true) minetest.remove_node(tpos) exting = true + elseif minetest.get_item_group(node.name, "lit_campfire") ~= 0 then + minetest.sound_play("fire_extinguish_flame", {pos = tpos, gain = 0.25, max_hear_distance = 16}, true) + local def = minetest.registered_nodes[node.name] + minetest.set_node(tpos, {name = def._mcl_campfires_smothered_form, param2 = node.param2}) + exting = true end end -- Has radius: lingering, extinguish all nodes in area @@ -996,10 +1001,16 @@ function mcl_potions._extinguish_nearby_fire(pos, radius) local nodes = minetest.find_nodes_in_area( {x=epos.x-radius,y=epos.y,z=epos.z-radius}, {x=epos.x+radius,y=epos.y,z=epos.z+radius}, - {"group:fire"}) + {"group:fire", "group:lit_campfire"}) for n=1, #nodes do + local node = minetest.get_node(nodes[n]) minetest.sound_play("fire_extinguish_flame", {pos = nodes[n], gain = 0.25, max_hear_distance = 16}, true) - minetest.remove_node(nodes[n]) + if minetest.get_item_group(node.name, "fire") ~= 0 then + minetest.remove_node(nodes[n]) + elseif minetest.get_item_group(node.name, "lit_campfire") ~= 0 then + local def = minetest.registered_nodes[node.name] + minetest.set_node(nodes[n], {name = def._mcl_campfires_smothered_form, param2 = node.param2}) + end exting = true end end