From 820b97f065a5c9ca76516d1937e72fae78b1a6de Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 21 Jun 2022 12:52:54 +0200 Subject: [PATCH 1/7] fix soem codestyle stuff in mcl_cauldrons --- mods/ITEMS/mcl_cauldrons/init.lua | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/mods/ITEMS/mcl_cauldrons/init.lua b/mods/ITEMS/mcl_cauldrons/init.lua index 55866f5cc..e78b0ce3f 100644 --- a/mods/ITEMS/mcl_cauldrons/init.lua +++ b/mods/ITEMS/mcl_cauldrons/init.lua @@ -5,7 +5,7 @@ local S = minetest.get_translator(minetest.get_current_modname()) -- TODO: Extinguish fire of burning entities -- Convenience function because the cauldron nodeboxes are very similar -local create_cauldron_nodebox = function(water_level) +local function create_cauldron_nodebox(water_level) local floor_y if water_level == 0 then -- empty floor_y = -0.1875 @@ -36,10 +36,6 @@ local create_cauldron_nodebox = function(water_level) } end -local cauldron_nodeboxes = {} -for w=0,3 do - cauldron_nodeboxes[w] = create_cauldron_nodebox(w) -end -- Empty cauldron @@ -55,7 +51,7 @@ minetest.register_node("mcl_cauldrons:cauldron", { paramtype = "light", is_ground_content = false, groups = {pickaxey=1, deco_block=1, cauldron=1}, - node_box = cauldron_nodeboxes[0], + node_box = create_cauldron_nodebox(0), selection_box = { type = "regular" }, tiles = { "mcl_cauldrons_cauldron_inner.png^mcl_cauldrons_cauldron_top.png", @@ -68,7 +64,7 @@ minetest.register_node("mcl_cauldrons:cauldron", { }) -- Template function for cauldrons with water -local register_filled_cauldron = function(water_level, description, river_water) +local function register_filled_cauldron(water_level, description, river_water) local id = "mcl_cauldrons:cauldron_"..water_level local water_tex if river_water then @@ -85,8 +81,8 @@ local register_filled_cauldron = function(water_level, description, river_water) paramtype = "light", is_ground_content = false, groups = {pickaxey=1, not_in_creative_inventory=1, cauldron=(1+water_level), cauldron_filled=water_level, comparator_signal=water_level}, - node_box = cauldron_nodeboxes[water_level], - collision_box = cauldron_nodeboxes[0], + node_box = create_cauldron_nodebox(water_level), + collision_box = create_cauldron_nodebox(0), selection_box = { type = "regular" }, tiles = { "("..water_tex..")^mcl_cauldrons_cauldron_top.png", From 9937224997bd604c5bfd04d0ff68e18317c18493 Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 21 Jun 2022 12:58:19 +0200 Subject: [PATCH 2/7] Add lava filled cauldron --- mods/ITEMS/mcl_cauldrons/init.lua | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mods/ITEMS/mcl_cauldrons/init.lua b/mods/ITEMS/mcl_cauldrons/init.lua index e78b0ce3f..02cc41d52 100644 --- a/mods/ITEMS/mcl_cauldrons/init.lua +++ b/mods/ITEMS/mcl_cauldrons/init.lua @@ -64,12 +64,15 @@ minetest.register_node("mcl_cauldrons:cauldron", { }) -- Template function for cauldrons with water -local function register_filled_cauldron(water_level, description, river_water) +local function register_filled_cauldron(water_level, description, liquid) local id = "mcl_cauldrons:cauldron_"..water_level local water_tex - if river_water then + if liquid == "river_water" then id = id .. "r" water_tex = "default_river_water_source_animated.png^[verticalframe:16:0" + elseif liquid == "lava" then + id = id .. "_lava" + water_tex = "default_lava_source_animated.png^[verticalframe:16:0" else water_tex = "default_water_source_animated.png^[verticalframe:16:0" end @@ -106,10 +109,14 @@ register_filled_cauldron(1, S("Cauldron (1/3 Water)")) register_filled_cauldron(2, S("Cauldron (2/3 Water)")) register_filled_cauldron(3, S("Cauldron (3/3 Water)")) +register_filled_cauldron(1, S("Cauldron (1/3 Lava)"),"lava") +register_filled_cauldron(2, S("Cauldron (2/3 Lava)"),"lava") +register_filled_cauldron(3, S("Cauldron (3/3 Lava)"),"lava") + if minetest.get_modpath("mclx_core") then - register_filled_cauldron(1, S("Cauldron (1/3 River Water)"), true) - register_filled_cauldron(2, S("Cauldron (2/3 River Water)"), true) - register_filled_cauldron(3, S("Cauldron (3/3 River Water)"), true) + register_filled_cauldron(1, S("Cauldron (1/3 River Water)"),"river_water") + register_filled_cauldron(2, S("Cauldron (2/3 River Water)"),"river_water") + register_filled_cauldron(3, S("Cauldron (3/3 River Water)"),"river_water") end minetest.register_craft({ From 7a8d20e1243b885de90afb0f92b567f5ffc9cfa9 Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 21 Jun 2022 13:05:24 +0200 Subject: [PATCH 3/7] take lava from cauldron with bucket --- mods/ITEMS/mcl_buckets/init.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 85215caaf..f70767e52 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -282,6 +282,12 @@ local function on_place_bucket_empty(itemstack, user, pointed_thing) new_bucket = ItemStack("mcl_buckets:bucket_river_water") end sound_take("mclx_core:river_water_source", pointed_thing.under) + elseif nn == "mcl_cauldrons:cauldron_3_lava" then + set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) + if not is_creative_enabled(user:get_player_name()) then + new_bucket = ItemStack("mcl_buckets:bucket_lava") + end + sound_take("mcl_core:lava_source", pointed_thing.under) end if new_bucket then return give_bucket(new_bucket, itemstack, user) From 685cba682139bbf78b1aa563a7f4b1cfaa127596 Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 21 Jun 2022 13:42:25 +0200 Subject: [PATCH 4/7] Allow placing lava into cauldrons --- mods/ITEMS/mcl_buckets/register.lua | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/register.lua b/mods/ITEMS/mcl_buckets/register.lua index 1a7c8fe14..15eb4e550 100644 --- a/mods/ITEMS/mcl_buckets/register.lua +++ b/mods/ITEMS/mcl_buckets/register.lua @@ -29,11 +29,21 @@ if mod_mcl_core then end end, source_take = {"mcl_core:lava_source", "mcl_nether:nether_lava_source"}, - on_take = function(user) - if has_awards and user and user:is_player() then - awards.unlock(user:get_player_name(), "mcl:hotStuff") - end - end, + on_take = function(user) + if has_awards and user and user:is_player() then + awards.unlock(user:get_player_name(), "mcl:hotStuff") + end + end, + extra_check = function(pos, placer) + local nn = minetest.get_node(pos).name + if minetest.get_item_group(nn, "cauldron") ~= 0 then + if nn ~= "mcl_cauldrons:cauldron_3_lava" then + minetest.set_node(pos, {name="mcl_cauldrons:cauldron_3_lava"}) + end + sound_place("mcl_core:lava_source", pos) + return false, true + end + end, bucketname = "mcl_buckets:bucket_lava", inventory_image = "bucket_lava.png", name = S("Lava Bucket"), From 3a7022ab66b430a7bbe06d93135942a9ea184c82 Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 21 Jun 2022 13:51:06 +0200 Subject: [PATCH 5/7] Clean up buckets and cauldrons a little bit --- mods/ITEMS/mcl_buckets/init.lua | 23 +++++++++-------------- mods/ITEMS/mcl_buckets/register.lua | 7 ------- mods/ITEMS/mcl_cauldrons/init.lua | 20 ++++++-------------- 3 files changed, 15 insertions(+), 35 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index f70767e52..148df7711 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -29,15 +29,15 @@ local is_creative_enabled = minetest.is_creative_enabled local is_protected = minetest.is_protected local record_protection_violation = minetest.record_protection_violation -if mod_mcl_core then - minetest.register_craft({ - output = "mcl_buckets:bucket_empty 1", - recipe = { - {"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"}, - {"", "mcl_core:iron_ingot", ""}, - }, - }) -end + +minetest.register_craft({ + output = "mcl_buckets:bucket_empty 1", + recipe = { + {"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"}, + {"", "mcl_core:iron_ingot", ""}, + }, +}) + mcl_buckets = { liquids = {}, @@ -88,9 +88,7 @@ end local pointable_sources = {} local function bucket_raycast(user) - --local pos = user:get_pos() local pos = user:get_pos() - --local pos = vector.add(user:get_pos(), user:get_bone_position("Head_Control")) pos.y = pos.y + user:get_properties().eye_height local look_dir = user:get_look_dir() look_dir = vector.multiply(look_dir, 5) @@ -100,7 +98,6 @@ local function bucket_raycast(user) if ray then for pointed_thing in ray do if pointed_thing and pointable_sources[get_node(pointed_thing.above).name] then - --minetest.chat_send_all("found!") return {under=pointed_thing.under,above=pointed_thing.above} end end @@ -242,7 +239,6 @@ local function on_place_bucket_empty(itemstack, user, pointed_thing) if liquid_name then local liquid_def = mcl_buckets.liquids[liquid_name] if liquid_def then - --minetest.chat_send_all("test") -- Fill bucket, but not in Creative Mode -- FIXME: remove this line --if not is_creative_enabled(user:get_player_name()) then @@ -372,7 +368,6 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { _doc_items_longdesc = S("A bucket can be used to collect and release liquids."), _doc_items_usagehelp = S("Punch a liquid source to collect it. You can then use the filled bucket to place the liquid somewhere else."), _tt_help = S("Collects liquids"), - --liquids_pointable = true, inventory_image = "bucket.png", stack_max = 16, _on_dispense = function(stack, pos, droppos, dropnode, dropdir) diff --git a/mods/ITEMS/mcl_buckets/register.lua b/mods/ITEMS/mcl_buckets/register.lua index 15eb4e550..365966724 100644 --- a/mods/ITEMS/mcl_buckets/register.lua +++ b/mods/ITEMS/mcl_buckets/register.lua @@ -10,13 +10,6 @@ local function sound_place(itemname, pos) end end ---[[local sound_take = function(itemname, pos) - local def = minetest.registered_nodes[itemname] - if def and def.sounds and def.sounds.dug then - minetest.sound_play(def.sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) - end -end]] - if mod_mcl_core then -- Lava bucket mcl_buckets.register_liquid({ diff --git a/mods/ITEMS/mcl_cauldrons/init.lua b/mods/ITEMS/mcl_cauldrons/init.lua index 02cc41d52..cbe19138e 100644 --- a/mods/ITEMS/mcl_cauldrons/init.lua +++ b/mods/ITEMS/mcl_cauldrons/init.lua @@ -36,8 +36,6 @@ local function create_cauldron_nodebox(water_level) } end - - -- Empty cauldron minetest.register_node("mcl_cauldrons:cauldron", { description = S("Cauldron"), @@ -105,18 +103,12 @@ local function register_filled_cauldron(water_level, description, liquid) end -- Filled cauldrons (3 levels) -register_filled_cauldron(1, S("Cauldron (1/3 Water)")) -register_filled_cauldron(2, S("Cauldron (2/3 Water)")) -register_filled_cauldron(3, S("Cauldron (3/3 Water)")) - -register_filled_cauldron(1, S("Cauldron (1/3 Lava)"),"lava") -register_filled_cauldron(2, S("Cauldron (2/3 Lava)"),"lava") -register_filled_cauldron(3, S("Cauldron (3/3 Lava)"),"lava") - -if minetest.get_modpath("mclx_core") then - register_filled_cauldron(1, S("Cauldron (1/3 River Water)"),"river_water") - register_filled_cauldron(2, S("Cauldron (2/3 River Water)"),"river_water") - register_filled_cauldron(3, S("Cauldron (3/3 River Water)"),"river_water") +for i=1,3 do + register_filled_cauldron(i, S("Cauldron (" ..i .. "/3 Water)")) + register_filled_cauldron(i, S("Cauldron (" ..i .. "/3 Water)"),"lava") + if minetest.get_modpath("mclx_core") then + register_filled_cauldron(i, S("Cauldron (" ..i .. "/3 Water)"),"river_water") + end end minetest.register_craft({ From 1401f398ae53b9e902bf4490a722d2f8f3b954ad Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 21 Jun 2022 14:24:15 +0200 Subject: [PATCH 6/7] globalstep instead of abm to extinguish objects --- mods/ITEMS/mcl_cauldrons/init.lua | 35 +++++++++++++++++++------------ 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/mods/ITEMS/mcl_cauldrons/init.lua b/mods/ITEMS/mcl_cauldrons/init.lua index cbe19138e..1832103fa 100644 --- a/mods/ITEMS/mcl_cauldrons/init.lua +++ b/mods/ITEMS/mcl_cauldrons/init.lua @@ -120,19 +120,28 @@ minetest.register_craft({ } }) -minetest.register_abm({ - label = "cauldrons", - nodenames = {"group:cauldron_filled"}, - interval = 0.5, - chance = 1, - action = function(pos, node) - for _, obj in pairs(minetest.get_objects_inside_radius(pos, 0.4)) do - if mcl_burning.is_burning(obj) then - mcl_burning.extinguish(obj) - local new_group = minetest.get_item_group(node.name, "cauldron_filled") - 1 - minetest.swap_node(pos, {name = "mcl_cauldrons:cauldron" .. (new_group == 0 and "" or "_" .. new_group)}) - break +local function cauldron_extinguish(obj,pos) + local node = minetest.get_node(pos) + if mcl_burning.is_burning(obj) then + mcl_burning.extinguish(obj) + local new_group = minetest.get_item_group(node.name, "cauldron_filled") - 1 + minetest.swap_node(pos, {name = "mcl_cauldrons:cauldron" .. (new_group == 0 and "" or "_" .. new_group)}) + end +end + +minetest.register_globalstep(function(dtime) + for _,pl in pairs(minetest.get_connected_players()) do + local n = minetest.find_node_near(pl:get_pos(),0.4,{"group:cauldron_filled"},true) + if n and not minetest.get_node(n).name:find("lava") then + cauldron_extinguish(pl,n) + end + end + for _,ent in pairs(minetest.luaentities) do + if ent.object:get_pos() then + local n = minetest.find_node_near(ent.object:get_pos(),0.4,{"group:cauldron_filled"},true) + if n and not minetest.get_node(n).name:find("lava") then + cauldron_extinguish(ent.object,n) end end end -}) +end) From ca6cf81e24a0b15bee6a315394de9f6848db7d8a Mon Sep 17 00:00:00 2001 From: cora Date: Wed, 22 Jun 2022 11:56:25 +0200 Subject: [PATCH 7/7] set objects on fire when in lava cauldron --- mods/ITEMS/mcl_cauldrons/init.lua | 10 +++++++++- mods/ITEMS/mcl_cauldrons/mod.conf | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_cauldrons/init.lua b/mods/ITEMS/mcl_cauldrons/init.lua index 1832103fa..6a8270794 100644 --- a/mods/ITEMS/mcl_cauldrons/init.lua +++ b/mods/ITEMS/mcl_cauldrons/init.lua @@ -129,18 +129,26 @@ local function cauldron_extinguish(obj,pos) end end +local etime = 0 minetest.register_globalstep(function(dtime) + etime = dtime + etime + if etime < 0.5 then return end + etime = 0 for _,pl in pairs(minetest.get_connected_players()) do local n = minetest.find_node_near(pl:get_pos(),0.4,{"group:cauldron_filled"},true) if n and not minetest.get_node(n).name:find("lava") then cauldron_extinguish(pl,n) + elseif n and minetest.get_node(n).name:find("lava") then + mcl_burning.set_on_fire(pl, 5) end end for _,ent in pairs(minetest.luaentities) do - if ent.object:get_pos() then + if ent.object:get_pos() and ent.is_mob then local n = minetest.find_node_near(ent.object:get_pos(),0.4,{"group:cauldron_filled"},true) if n and not minetest.get_node(n).name:find("lava") then cauldron_extinguish(ent.object,n) + elseif n and minetest.get_node(n).name:find("lava") then + mcl_burning.set_on_fire(ent.object, 5) end end end diff --git a/mods/ITEMS/mcl_cauldrons/mod.conf b/mods/ITEMS/mcl_cauldrons/mod.conf index 4787d60f9..36d5b303b 100644 --- a/mods/ITEMS/mcl_cauldrons/mod.conf +++ b/mods/ITEMS/mcl_cauldrons/mod.conf @@ -1,3 +1,3 @@ name = mcl_cauldrons depends = mcl_core, mcl_sounds -optional_depends = mclx_core, doc +optional_depends = mclx_core, doc, mcl_burning