From 506629127f7d7d299b761d2f0351b7e39912f6a1 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 30 Jun 2023 13:16:57 +0200 Subject: [PATCH] Add river water support for cauldrons --- src/cooking.lua | 87 +++++++++++++++--- ..._cauldron_top_anim_boiling_river_water.png | Bin 0 -> 642 bytes .../xdecor_cauldron_top_idle_river_water.png | Bin 0 -> 303 bytes 3 files changed, 75 insertions(+), 12 deletions(-) create mode 100644 textures/xdecor_cauldron_top_anim_boiling_river_water.png create mode 100644 textures/xdecor_cauldron_top_idle_river_water.png diff --git a/src/cooking.lua b/src/cooking.lua index 43b12de..178400e 100644 --- a/src/cooking.lua +++ b/src/cooking.lua @@ -49,24 +49,36 @@ function cauldron.filling(pos, node, clicker, itemstack) local inv = clicker:get_inventory() local wield_item = clicker:get_wielded_item():get_name() - if wield_item:sub(1,7) == "bucket:" then - if wield_item:sub(-6) == "_empty" and not (node.name:sub(-6) == "_empty") then + do + if wield_item == "bucket:bucket_empty" and node.name:sub(-6) ~= "_empty" then + local bucket_item + if node.name:sub(-11) == "river_water" then + bucket_item = "bucket:bucket_river_water 1" + else + bucket_item = "bucket:bucket_water 1" + end if itemstack:get_count() > 1 then - if inv:room_for_item("main", "bucket:bucket_water 1") then + if inv:room_for_item("main", bucket_item) then itemstack:take_item() - inv:add_item("main", "bucket:bucket_water 1") + inv:add_item("main", bucket_item) else minetest.chat_send_player(clicker:get_player_name(), S("No room in your inventory to add a bucket of water.")) return itemstack end else - itemstack:replace("bucket:bucket_water") + itemstack:replace(bucket_item) end minetest.set_node(pos, {name = "xdecor:cauldron_empty", param2 = node.param2}) - elseif wield_item:sub(-6) == "_water" and node.name:sub(-6) == "_empty" then - minetest.set_node(pos, {name = "xdecor:cauldron_idle", param2 = node.param2}) + elseif minetest.get_item_group(wield_item, "water_bucket") == 1 and node.name:sub(-6) == "_empty" then + local newnode + if wield_item == "bucket:bucket_river_water" then + newnode = "xdecor:cauldron_idle_river_water" + else + newnode = "xdecor:cauldron_idle" + end + minetest.set_node(pos, {name = newnode, param2 = node.param2}) itemstack:replace("bucket:bucket_empty") end @@ -81,7 +93,12 @@ function cauldron.idle_timer(pos) end local node = minetest.get_node(pos) - minetest.set_node(pos, {name = "xdecor:cauldron_boiling", param2 = node.param2}) + if node.name:sub(-11) == "river_water" then + node.name = "xdecor:cauldron_boiling_river_water" + else + node.name = "xdecor:cauldron_boiling" + end + minetest.set_node(pos, node) return true end @@ -128,7 +145,13 @@ function cauldron.boiling_timer(pos) local node_under = {x = pos.x, y = pos.y - 1, z = pos.z} if not minetest.get_node(node_under).name:find("fire") then - minetest.set_node(pos, {name = "xdecor:cauldron_idle", param2 = node.param2}) + local newnode + if node.name:sub(-11) == "river_water" then + newnode = "xdecor:cauldron_idle_river_water" + else + newnode = "xdecor:cauldron_idle" + end + minetest.set_node(pos, {name = newnode, param2 = node.param2}) end return true @@ -174,7 +197,7 @@ xdecor.register("cauldron_empty", { }) xdecor.register("cauldron_idle", { - description = S("Cauldron (idle)"), + description = S("Cauldron with Water (idle)"), groups = {cracky=2, oddly_breakable_by_hand=1, not_in_creative_inventory=1}, on_rotate = screwdriver.rotate_simple, tiles = {"xdecor_cauldron_top_idle.png", "xdecor_cauldron_sides.png"}, @@ -187,8 +210,22 @@ xdecor.register("cauldron_idle", { on_timer = cauldron.idle_timer, }) +xdecor.register("cauldron_idle_river_water", { + description = S("Cauldron with River Water (idle)"), + groups = {cracky=2, oddly_breakable_by_hand=1, not_in_creative_inventory=1}, + on_rotate = screwdriver.rotate_simple, + tiles = {"xdecor_cauldron_top_idle_river_water.png", "xdecor_cauldron_sides.png"}, + sounds = default.node_sound_metal_defaults(), + drop = "xdecor:cauldron_empty", + infotext = S("Cauldron (idle)"), + collision_box = xdecor.pixelbox(16, cauldron.cbox), + on_rightclick = cauldron.filling, + on_construct = cauldron.idle_construct, + on_timer = cauldron.idle_timer, +}) + xdecor.register("cauldron_boiling", { - description = S("Cauldron (active)"), + description = S("Cauldron with Water (active)"), groups = {cracky=2, oddly_breakable_by_hand=1, not_in_creative_inventory=1}, on_rotate = screwdriver.rotate_simple, drop = "xdecor:cauldron_empty", @@ -211,8 +248,34 @@ xdecor.register("cauldron_boiling", { end, }) +xdecor.register("cauldron_boiling_river_water", { + description = S("Cauldron with River Water (active)"), + groups = {cracky=2, oddly_breakable_by_hand=1, not_in_creative_inventory=1}, + on_rotate = screwdriver.rotate_simple, + drop = "xdecor:cauldron_empty", + infotext = S("Cauldron (active) - Drop foods inside to make a soup"), + damage_per_second = 2, + tiles = { + { + name = "xdecor_cauldron_top_anim_boiling_river_water.png", + animation = {type = "vertical_frames", length = 3.0} + }, + "xdecor_cauldron_sides.png" + }, + sounds = default.node_sound_metal_defaults(), + collision_box = xdecor.pixelbox(16, cauldron.cbox), + on_rightclick = cauldron.filling, + on_construct = cauldron.boiling_construct, + on_timer = cauldron.boiling_timer, + on_destruct = function(pos) + cauldron.stop_sound(pos) + end, +}) + + + xdecor.register("cauldron_soup", { - description = S("Cauldron (active)"), + description = S("Cauldron with Soup (active)"), groups = {cracky = 2, oddly_breakable_by_hand = 1, not_in_creative_inventory = 1}, on_rotate = screwdriver.rotate_simple, drop = "xdecor:cauldron_empty", diff --git a/textures/xdecor_cauldron_top_anim_boiling_river_water.png b/textures/xdecor_cauldron_top_anim_boiling_river_water.png new file mode 100644 index 0000000000000000000000000000000000000000..083f8103e65460f04a260d553299429fc0c7d0fe GIT binary patch literal 642 zcmV-|0)737P)SfwKDXI2r_)Hr>_55MNXYC+-SID(%QL9cIIq@7$n8kc?nu4r zNXP6*xadE(+DO~+NWkhyx#>vH?nt@lNZau01tuH-00Fj1L_t(|0Zh(Sg2f;VKvCSn z3sZOB{~m{W@8>}hLg*E_V_d|fVvKRdcF<Ah46tcY7fgSKG zE6nPqeW2_6cmo5#4piBp^zB#`6@pciP-%u~?yDxr3otT*F!{2UGbY0ZMjViW_th65 zgEl~tCwM_wmk5|t7jW~gu6cz2=IUUzVHgI$Fgq)_gs`Lttt+uyC*I!w`DV96k<_tM zX>--hAHQV#xVO9KKhOiK2Rjc27LT!O9!WedBZ2X_e4fYZkr(l(gL8<-9ybq~^Z*8g z1bvRmgJ0vp&SQn-`rz6Jgw3P%!ODYLA4^dl^SJdP9{sU5eXtt90Im6puPMmG_BlA2C}Gb{-`}?SXK>{dll=;MIde{C)mBmUchXzECIkLp;8U+n2)s z_d(sH2as;}L+uOgq>uH_dkUtHh($07*qoM6N<$g8pGR5C8xG literal 0 HcmV?d00001 diff --git a/textures/xdecor_cauldron_top_idle_river_water.png b/textures/xdecor_cauldron_top_idle_river_water.png new file mode 100644 index 0000000000000000000000000000000000000000..a7456ec46ab2b1f5b11ef99d5334610492192df5 GIT binary patch literal 303 zcmV+~0nq-5P)70Tsx}$;qMuga)7iKt4kh zpi*)`f*=Tj;5_hb+xGh}Yi&eK)T*+zeKg~vnO>#sjc$57?m66Gz~*NVfC;80)&1gY zx`!ZuEet63$T#3-SPnk>8Ab;?Eyo8K9|NI9v;6r$YfUOjLhUyguwfR!5E+XD zOz$W@luDdVdIt>H9Du z0PFaPLOMs*i>Ym*0Kbsu?A2g*usJ~S<-=Thz5kR)rjJV*x#<7^002ovPDHLkV1ks~ BdFKEC literal 0 HcmV?d00001