From dd58bed5d107a58d086c3268f88cae0b2bd9a373 Mon Sep 17 00:00:00 2001 From: cora Date: Fri, 25 Nov 2022 03:09:21 +0100 Subject: [PATCH 01/16] refactor fish bucket code to not use bucket api it was clearly not made for this --- mods/ITEMS/mcl_buckets/register.lua | 78 ++++++++++++++++++----------- 1 file changed, 49 insertions(+), 29 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/register.lua b/mods/ITEMS/mcl_buckets/register.lua index daaa3116a..baea8ce3e 100644 --- a/mods/ITEMS/mcl_buckets/register.lua +++ b/mods/ITEMS/mcl_buckets/register.lua @@ -120,37 +120,57 @@ minetest.register_craft({ }) -- Fish Buckets -fish_names = { - { techname = "cod", name = "Cod" }, - { techname = "salmon", name = "Salmon" }, - { techname = "axolotl", name = "Axolotl" }, - --{ techname = "pufferfish", name = "Pufferfish" } FIXME: Uncomment when pufferfish mobs are added. - { techname = "tropical_fish", name = "Tropical Fish" } +local fish_names = { + ["cod"] = "Cod", + ["salmon"] = "Salmon", + ["tropical_fish"] = "Tropical Fish", + ["axolotl"] = "Axolotl", + --["pufferfish"] = "Pufferfish", --FIXME add pufferfish } -for _, fish in pairs(fish_names) do - mcl_buckets.register_liquid({ - bucketname = "mcl_buckets:bucket_" .. fish.techname, - source_place = function(pos) - minetest.add_entity(pos, "mobs_mc:" .. fish.techname) - return "mcl_core:water_source" - end, - source_take = {"mobs_mc:" .. fish.techname}, - inventory_image = fish.techname .. "_bucket.png", - name = S("Bucket of @1", S(fish.name)), - longdesc = S("This bucket is filled with water and @1.", S(fish.name)), - usagehelp = S("Place it to empty the bucket and place a @1. Obtain by right clicking on a @2 with a bucket of water.", S(fish.name), S(fish.name)), - tt_help = S("Places a water source and a @1.", S(fish.name)), - extra_check = function(pos, placer) - local dim = mcl_worlds.pos_to_dimension(pos) - if dim == "nether" then - minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true) - return false, true - else - return true, true +local fishbucket_prefix = "mcl_buckets:bucket_" + +local function on_place_fish(itemstack, placer, pointed_thing) + local pos = pointed_thing.above + local n = minetest.get_node_or_nil(pos) + if n and minetest.registered_nodes[n.name].buildable_to or n.name == "mcl_portals:portal" then + local fish = itemstack:get_name():gsub(fishbucket_prefix,"") + if fish_names[fish] then + local o = minetest.add_entity(pos, "mobs_mc:" .. fish) + minetest.set_node(pos,{name = "mcl_core:water_source"}) + if not minetest.is_creative_enabled(placer:get_player_name()) then + itemstack:set_name("mcl_buckets:bucket_empty") end - end, - }) - minetest.register_alias("mcl_fishing:bucket_" .. fish.techname, "mcl_buckets:bucket_" .. fish.techname) + end + end + return itemstack end +for techname, fishname in pairs(fish_names) do + minetest.register_craftitem(fishbucket_prefix .. techname, { + description = S("Bucket of @1", S(fishname)), + _doc_items_longdesc = S("This bucket is filled with water and @1.", S(fishname)), + _doc_items_usagehelp = S("Place it to empty the bucket and place a @1. Obtain by right clicking on a @2 with a bucket of water.", S(fishname), S(fishname)), + _tt_help = S("Places a water source and a @1.", S(fishname)), + inventory_image = techname .. "_bucket.png", + stack_max = 1, + groups = {bucket = 1, fish_bucket = 1}, + liquids_pointable = false, + on_place = on_place_fish, + on_secondary_use = on_place_fish, + _on_dispense = function(stack, pos, droppos, dropnode, dropdir) + local buildable = registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal" + if not buildable then return stack end + local result, take_bucket = get_extra_check(def.extra_check, droppos, nil) + if result then -- Fail placement of liquid if result is false + place_liquid(droppos, get_node_place(def.source_place, droppos)) + end + if take_bucket then + stack:set_name("mcl_buckets:bucket_empty") + end + return stack + end, + }) + + minetest.register_alias("mcl_fishing:bucket_" .. techname, "mcl_buckets:bucket_" .. techname) +end From 99db678a44dadd871f051d06904428483b6680e9 Mon Sep 17 00:00:00 2001 From: cora Date: Fri, 25 Nov 2022 03:21:35 +0100 Subject: [PATCH 02/16] Fish buckets set properties from bucket item meta --- mods/ITEMS/mcl_buckets/register.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/register.lua b/mods/ITEMS/mcl_buckets/register.lua index baea8ce3e..f2baaf7a5 100644 --- a/mods/ITEMS/mcl_buckets/register.lua +++ b/mods/ITEMS/mcl_buckets/register.lua @@ -131,12 +131,17 @@ local fish_names = { local fishbucket_prefix = "mcl_buckets:bucket_" local function on_place_fish(itemstack, placer, pointed_thing) - local pos = pointed_thing.above + local pos = pointed_thing.above or pointed_thing.under + if not pos then return end local n = minetest.get_node_or_nil(pos) - if n and minetest.registered_nodes[n.name].buildable_to or n.name == "mcl_portals:portal" then + if n.name and minetest.registered_nodes[n.name].buildable_to or n.name == "mcl_portals:portal" then local fish = itemstack:get_name():gsub(fishbucket_prefix,"") if fish_names[fish] then local o = minetest.add_entity(pos, "mobs_mc:" .. fish) + local props = itemstack:get_meta():get_string("properties") + if props ~= "" then + o:set_properties(minetest.deserialize(props)) + end minetest.set_node(pos,{name = "mcl_core:water_source"}) if not minetest.is_creative_enabled(placer:get_player_name()) then itemstack:set_name("mcl_buckets:bucket_empty") From 67e8f13a96355ed542a8c51f8ffae419a372f509 Mon Sep 17 00:00:00 2001 From: cora Date: Fri, 25 Nov 2022 03:30:06 +0100 Subject: [PATCH 03/16] Axolotl whitespace fixes --- mods/ENTITIES/mobs_mc/axolotl.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/axolotl.lua b/mods/ENTITIES/mobs_mc/axolotl.lua index 96cf5e069..0a444382e 100644 --- a/mods/ENTITIES/mobs_mc/axolotl.lua +++ b/mods/ENTITIES/mobs_mc/axolotl.lua @@ -38,7 +38,7 @@ local axolotl = { hp_max = 14, xp_min = 1, xp_max = 7, - + head_swivel = "head.control", bone_eye_height = -1, head_eye_height = -0.5, @@ -61,7 +61,7 @@ local axolotl = { {"mobs_mc_axolotl_pink.png"}, {"mobs_mc_axolotl_black.png"}, {"mobs_mc_axolotl_purple.png"}, - {"mobs_mc_axolotl_white.png"} + {"mobs_mc_axolotl_white.png"} }, sounds = { random = "mobs_mc_axolotl", @@ -101,7 +101,7 @@ local axolotl = { reach = 2, attack_type = "dogfight", attack_animals = true, - specific_attack = { + specific_attack = { "extra_mobs_cod", "mobs_mc:sheep", "extra_mobs_glow_squid", From 665e8a06a22cecb1636d427a66256bcb47e91e11 Mon Sep 17 00:00:00 2001 From: cora Date: Fri, 25 Nov 2022 03:30:23 +0100 Subject: [PATCH 04/16] Save axolotl properties in item meta on bucket pickup --- mods/ENTITIES/mobs_mc/axolotl.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/axolotl.lua b/mods/ENTITIES/mobs_mc/axolotl.lua index 0a444382e..830f1f1bc 100644 --- a/mods/ENTITIES/mobs_mc/axolotl.lua +++ b/mods/ENTITIES/mobs_mc/axolotl.lua @@ -84,8 +84,13 @@ local axolotl = { on_rightclick = function(self, clicker) if clicker:get_wielded_item():get_name() == "mcl_buckets:bucket_water" then - self.object:remove() - clicker:set_wielded_item("mcl_buckets:bucket_axolotl") + if clicker:set_wielded_item("mcl_buckets:bucket_axolotl") then + local it = clicker:get_wielded_item() + local m = it:get_meta() + m:set_string("properties",minetest.serialize(self.object:get_properties())) + clicker:set_wielded_item(it) + self.object:remove() + end awards.unlock(clicker:get_player_name(), "mcl:cutestPredator") return end @@ -132,7 +137,7 @@ local axolotl = { self.object:set_rotation({x=0,y=(atan(vec.z / vec.x) + 3 * pi / 2) - self.rotate,z=0}) end end - end + end, } mcl_mobs:register_mob("mobs_mc:axolotl", axolotl) From d3349396b4876186c54bcf42ba0611f03b68d52f Mon Sep 17 00:00:00 2001 From: cora Date: Fri, 25 Nov 2022 03:30:44 +0100 Subject: [PATCH 05/16] Save tropical fish properties in item meta on bucket pickup --- mods/ENTITIES/mobs_mc/tropical_fish.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/tropical_fish.lua b/mods/ENTITIES/mobs_mc/tropical_fish.lua index 04ca5863b..f35aff4cf 100644 --- a/mods/ENTITIES/mobs_mc/tropical_fish.lua +++ b/mods/ENTITIES/mobs_mc/tropical_fish.lua @@ -104,8 +104,13 @@ local tropical_fish = { fear_height = 4, on_rightclick = function(self, clicker) if clicker:get_wielded_item():get_name() == "mcl_buckets:bucket_water" then - self.object:remove() - clicker:set_wielded_item("mcl_buckets:bucket_tropical_fish") + if clicker:set_wielded_item("mcl_buckets:bucket_tropical_fish") then + local it = clicker:get_wielded_item() + local m = it:get_meta() + m:set_string("properties",minetest.serialize(self.object:get_properties())) + clicker:set_wielded_item(it) + self.object:remove() + end awards.unlock(clicker:get_player_name(), "mcl:tacticalFishing") end end, From b4971b298db6a2ad0c64733b125f848250ba7b70 Mon Sep 17 00:00:00 2001 From: cora Date: Fri, 25 Nov 2022 03:33:36 +0100 Subject: [PATCH 06/16] Move fish bucket code to separate file --- mods/ITEMS/mcl_buckets/fishbuckets.lua | 62 ++++++++++++++++++++++++++ mods/ITEMS/mcl_buckets/init.lua | 1 + mods/ITEMS/mcl_buckets/register.lua | 61 ------------------------- 3 files changed, 63 insertions(+), 61 deletions(-) create mode 100644 mods/ITEMS/mcl_buckets/fishbuckets.lua diff --git a/mods/ITEMS/mcl_buckets/fishbuckets.lua b/mods/ITEMS/mcl_buckets/fishbuckets.lua new file mode 100644 index 000000000..51bdc99b7 --- /dev/null +++ b/mods/ITEMS/mcl_buckets/fishbuckets.lua @@ -0,0 +1,62 @@ +local S = minetest.get_translator(minetest.get_current_modname()) + +-- Fish Buckets +local fish_names = { + ["cod"] = "Cod", + ["salmon"] = "Salmon", + ["tropical_fish"] = "Tropical Fish", + ["axolotl"] = "Axolotl", + --["pufferfish"] = "Pufferfish", --FIXME add pufferfish +} + +local fishbucket_prefix = "mcl_buckets:bucket_" + +local function on_place_fish(itemstack, placer, pointed_thing) + local pos = pointed_thing.above or pointed_thing.under + if not pos then return end + local n = minetest.get_node_or_nil(pos) + if n.name and minetest.registered_nodes[n.name].buildable_to or n.name == "mcl_portals:portal" then + local fish = itemstack:get_name():gsub(fishbucket_prefix,"") + if fish_names[fish] then + local o = minetest.add_entity(pos, "mobs_mc:" .. fish) + local props = itemstack:get_meta():get_string("properties") + if props ~= "" then + o:set_properties(minetest.deserialize(props)) + end + minetest.set_node(pos,{name = "mcl_core:water_source"}) + if not minetest.is_creative_enabled(placer:get_player_name()) then + itemstack:set_name("mcl_buckets:bucket_empty") + end + end + end + return itemstack +end + +for techname, fishname in pairs(fish_names) do + minetest.register_craftitem(fishbucket_prefix .. techname, { + description = S("Bucket of @1", S(fishname)), + _doc_items_longdesc = S("This bucket is filled with water and @1.", S(fishname)), + _doc_items_usagehelp = S("Place it to empty the bucket and place a @1. Obtain by right clicking on a @2 with a bucket of water.", S(fishname), S(fishname)), + _tt_help = S("Places a water source and a @1.", S(fishname)), + inventory_image = techname .. "_bucket.png", + stack_max = 1, + groups = {bucket = 1, fish_bucket = 1}, + liquids_pointable = false, + on_place = on_place_fish, + on_secondary_use = on_place_fish, + _on_dispense = function(stack, pos, droppos, dropnode, dropdir) + local buildable = registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal" + if not buildable then return stack end + local result, take_bucket = get_extra_check(def.extra_check, droppos, nil) + if result then -- Fail placement of liquid if result is false + place_liquid(droppos, get_node_place(def.source_place, droppos)) + end + if take_bucket then + stack:set_name("mcl_buckets:bucket_empty") + end + return stack + end, + }) + + minetest.register_alias("mcl_fishing:bucket_" .. techname, "mcl_buckets:bucket_" .. techname) +end diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 7e47e7e07..0fc1537d4 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -358,3 +358,4 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { }) dofile(modpath.."/register.lua") +dofile(modpath.."/fishbuckets.lua") diff --git a/mods/ITEMS/mcl_buckets/register.lua b/mods/ITEMS/mcl_buckets/register.lua index f2baaf7a5..365966724 100644 --- a/mods/ITEMS/mcl_buckets/register.lua +++ b/mods/ITEMS/mcl_buckets/register.lua @@ -118,64 +118,3 @@ minetest.register_craft({ burntime = 1000, replacements = {{"mcl_buckets:bucket_lava", "mcl_buckets:bucket_empty"}}, }) - --- Fish Buckets -local fish_names = { - ["cod"] = "Cod", - ["salmon"] = "Salmon", - ["tropical_fish"] = "Tropical Fish", - ["axolotl"] = "Axolotl", - --["pufferfish"] = "Pufferfish", --FIXME add pufferfish -} - -local fishbucket_prefix = "mcl_buckets:bucket_" - -local function on_place_fish(itemstack, placer, pointed_thing) - local pos = pointed_thing.above or pointed_thing.under - if not pos then return end - local n = minetest.get_node_or_nil(pos) - if n.name and minetest.registered_nodes[n.name].buildable_to or n.name == "mcl_portals:portal" then - local fish = itemstack:get_name():gsub(fishbucket_prefix,"") - if fish_names[fish] then - local o = minetest.add_entity(pos, "mobs_mc:" .. fish) - local props = itemstack:get_meta():get_string("properties") - if props ~= "" then - o:set_properties(minetest.deserialize(props)) - end - minetest.set_node(pos,{name = "mcl_core:water_source"}) - if not minetest.is_creative_enabled(placer:get_player_name()) then - itemstack:set_name("mcl_buckets:bucket_empty") - end - end - end - return itemstack -end - -for techname, fishname in pairs(fish_names) do - minetest.register_craftitem(fishbucket_prefix .. techname, { - description = S("Bucket of @1", S(fishname)), - _doc_items_longdesc = S("This bucket is filled with water and @1.", S(fishname)), - _doc_items_usagehelp = S("Place it to empty the bucket and place a @1. Obtain by right clicking on a @2 with a bucket of water.", S(fishname), S(fishname)), - _tt_help = S("Places a water source and a @1.", S(fishname)), - inventory_image = techname .. "_bucket.png", - stack_max = 1, - groups = {bucket = 1, fish_bucket = 1}, - liquids_pointable = false, - on_place = on_place_fish, - on_secondary_use = on_place_fish, - _on_dispense = function(stack, pos, droppos, dropnode, dropdir) - local buildable = registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal" - if not buildable then return stack end - local result, take_bucket = get_extra_check(def.extra_check, droppos, nil) - if result then -- Fail placement of liquid if result is false - place_liquid(droppos, get_node_place(def.source_place, droppos)) - end - if take_bucket then - stack:set_name("mcl_buckets:bucket_empty") - end - return stack - end, - }) - - minetest.register_alias("mcl_fishing:bucket_" .. techname, "mcl_buckets:bucket_" .. techname) -end From ebf4678e545c73b01cef68641d43908eaa205a94 Mon Sep 17 00:00:00 2001 From: cora Date: Fri, 25 Nov 2022 03:33:59 +0100 Subject: [PATCH 07/16] mcl_buckets whitespace fixes --- mods/ITEMS/mcl_buckets/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 0fc1537d4..0851c3757 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -160,7 +160,7 @@ local function on_place_bucket(itemstack, user, pointed_thing) if not pointed_thing or pointed_thing.type ~= "node" then return end - + -- Call on_rightclick if the pointed node defines it local new_stack = mcl_util.call_on_rightclick(itemstack, user, pointed_thing) if new_stack then @@ -202,7 +202,7 @@ local function on_place_bucket_empty(itemstack, user, pointed_thing) if not use_select_box then pointed_thing = bucket_get_pointed_thing(user) end - + -- Must be pointing to node if not pointed_thing or pointed_thing.type ~= "node" then return itemstack From 708fcfb368066dbf12a7424d2cc29fe76f9ba5f6 Mon Sep 17 00:00:00 2001 From: cora Date: Fri, 25 Nov 2022 03:54:21 +0100 Subject: [PATCH 08/16] Axolotl: remove cod-inherited swarming code --- mods/ENTITIES/mobs_mc/axolotl.lua | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/axolotl.lua b/mods/ENTITIES/mobs_mc/axolotl.lua index 830f1f1bc..e686a36d6 100644 --- a/mods/ENTITIES/mobs_mc/axolotl.lua +++ b/mods/ENTITIES/mobs_mc/axolotl.lua @@ -115,29 +115,6 @@ local axolotl = { "mobs_mc_squid" }, runaway = true, - do_custom = function(self) - --[[ this is supposed to make them jump out the water but doesn't appear to work very well - self.object:set_bone_position("body", vector.new(0,1,0), vector.new(degrees(dir_to_pitch(self.object:get_velocity())) * -1 + 90,0,0)) - if minetest.get_item_group(self.standing_in, "water") ~= 0 then - if self.object:get_velocity().y < 5 then - self.object:add_velocity({ x = 0 , y = math.random(-.007, .007), z = 0 }) - end - end ---]] - for _,object in pairs(minetest.get_objects_inside_radius(self.object:get_pos(), 10)) do - local lp = object:get_pos() - local s = self.object:get_pos() - local vec = { - x = lp.x - s.x, - y = lp.y - s.y, - z = lp.z - s.z - } - if object and not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "extra_mobs_tropical_fish" then - self.state = "runaway" - self.object:set_rotation({x=0,y=(atan(vec.z / vec.x) + 3 * pi / 2) - self.rotate,z=0}) - end - end - end, } mcl_mobs:register_mob("mobs_mc:axolotl", axolotl) From d4c2501d6223be671bad06ccbba5c01673c8b4c6 Mon Sep 17 00:00:00 2001 From: cora Date: Fri, 25 Nov 2022 03:59:05 +0100 Subject: [PATCH 09/16] Axolotl cleanup, remove clutter --- mods/ENTITIES/mobs_mc/axolotl.lua | 32 ------------------------------- 1 file changed, 32 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/axolotl.lua b/mods/ENTITIES/mobs_mc/axolotl.lua index e686a36d6..f3bf9802d 100644 --- a/mods/ENTITIES/mobs_mc/axolotl.lua +++ b/mods/ENTITIES/mobs_mc/axolotl.lua @@ -1,34 +1,5 @@ ---MCmobs v0.4 ---maikerumine ---made for MC like Survival game ---License for code WTFPL and otherwise stated in readmes - -local pi = math.pi -local atann = math.atan -local atan = function(x) - if not x or x ~= x then - return 0 - else - return atann(x) - end -end - -local dir_to_pitch = function(dir) - local dir2 = vector.normalize(dir) - local xz = math.abs(dir.x) + math.abs(dir.z) - return -math.atan2(-dir.y, xz) -end - -local function degrees(rad) - return rad * 180.0 / math.pi -end - local S = minetest.get_translator(minetest.get_current_modname()) ---################### ---################### axolotl ---################### - local axolotl = { type = "animal", spawn_class = "water", @@ -74,7 +45,6 @@ local axolotl = { run_start = 61, run_end = 81, run_speed = 20, }, - -- This should should make axolotls breedable, but it doesn't. follow = { "mcl_fishing:clownfish_raw" }, @@ -96,7 +66,6 @@ local axolotl = { end if mcl_mobs:feed_tame(self, clicker, 1, true, false) then return end end, - makes_footstep_sound = false, fly = true, fly_in = { "mcl_core:water_source", "mclx_core:river_water_source" }, @@ -119,7 +88,6 @@ local axolotl = { mcl_mobs:register_mob("mobs_mc:axolotl", axolotl) - local water = 0 mcl_mobs:spawn_specific( From bb73e5f1cd4e381d3062540bbf58c639b8398182 Mon Sep 17 00:00:00 2001 From: cora Date: Fri, 25 Nov 2022 04:18:58 +0100 Subject: [PATCH 10/16] Make it possible to pick up fish with river water bucket --- mods/ENTITIES/mobs_mc/axolotl.lua | 3 ++- mods/ENTITIES/mobs_mc/cod.lua | 3 ++- mods/ENTITIES/mobs_mc/salmon.lua | 3 ++- mods/ENTITIES/mobs_mc/tropical_fish.lua | 3 ++- mods/ITEMS/mcl_buckets/fishbuckets.lua | 6 +++++- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/axolotl.lua b/mods/ENTITIES/mobs_mc/axolotl.lua index f3bf9802d..ead5ae453 100644 --- a/mods/ENTITIES/mobs_mc/axolotl.lua +++ b/mods/ENTITIES/mobs_mc/axolotl.lua @@ -53,7 +53,8 @@ local axolotl = { fear_height = 4, on_rightclick = function(self, clicker) - if clicker:get_wielded_item():get_name() == "mcl_buckets:bucket_water" then + local bn = clicker:get_wielded_item():get_name() + if bn == "mcl_buckets:bucket_water" or bn == "mcl_buckets:bucket_river_water" then if clicker:set_wielded_item("mcl_buckets:bucket_axolotl") then local it = clicker:get_wielded_item() local m = it:get_meta() diff --git a/mods/ENTITIES/mobs_mc/cod.lua b/mods/ENTITIES/mobs_mc/cod.lua index d22334bf8..e3529b3ee 100644 --- a/mods/ENTITIES/mobs_mc/cod.lua +++ b/mods/ENTITIES/mobs_mc/cod.lua @@ -102,7 +102,8 @@ local cod = { end end, on_rightclick = function(self, clicker) - if clicker:get_wielded_item():get_name() == "mcl_buckets:bucket_water" then + local bn = clicker:get_wielded_item():get_name() + if bn == "mcl_buckets:bucket_water" or bn == "mcl_buckets:bucket_river_water" then self.object:remove() clicker:set_wielded_item("mcl_buckets:bucket_cod") awards.unlock(clicker:get_player_name(), "mcl:tacticalFishing") diff --git a/mods/ENTITIES/mobs_mc/salmon.lua b/mods/ENTITIES/mobs_mc/salmon.lua index 954d9d390..d187e72ae 100644 --- a/mods/ENTITIES/mobs_mc/salmon.lua +++ b/mods/ENTITIES/mobs_mc/salmon.lua @@ -58,7 +58,8 @@ local salmon = { runaway = true, fear_height = 4, on_rightclick = function(self, clicker) - if clicker:get_wielded_item():get_name() == "mcl_buckets:bucket_water" then + local bn = clicker:get_wielded_item():get_name() + if bn == "mcl_buckets:bucket_water" or bn == "mcl_buckets:bucket_river_water" then self.object:remove() clicker:set_wielded_item("mcl_buckets:bucket_salmon") awards.unlock(clicker:get_player_name(), "mcl:tacticalFishing") diff --git a/mods/ENTITIES/mobs_mc/tropical_fish.lua b/mods/ENTITIES/mobs_mc/tropical_fish.lua index f35aff4cf..113f2d401 100644 --- a/mods/ENTITIES/mobs_mc/tropical_fish.lua +++ b/mods/ENTITIES/mobs_mc/tropical_fish.lua @@ -103,7 +103,8 @@ local tropical_fish = { runaway = true, fear_height = 4, on_rightclick = function(self, clicker) - if clicker:get_wielded_item():get_name() == "mcl_buckets:bucket_water" then + local bn = clicker:get_wielded_item():get_name() + if bn == "mcl_buckets:bucket_water" or bn == "mcl_buckets:bucket_river_water" then if clicker:set_wielded_item("mcl_buckets:bucket_tropical_fish") then local it = clicker:get_wielded_item() local m = it:get_meta() diff --git a/mods/ITEMS/mcl_buckets/fishbuckets.lua b/mods/ITEMS/mcl_buckets/fishbuckets.lua index 51bdc99b7..b1de5e13e 100644 --- a/mods/ITEMS/mcl_buckets/fishbuckets.lua +++ b/mods/ITEMS/mcl_buckets/fishbuckets.lua @@ -23,7 +23,11 @@ local function on_place_fish(itemstack, placer, pointed_thing) if props ~= "" then o:set_properties(minetest.deserialize(props)) end - minetest.set_node(pos,{name = "mcl_core:water_source"}) + local water = "mcl_core:water_source" + if n.name == "mclx_core:river_water_source" then + water = n.name + end + minetest.set_node(pos,{name = water}) if not minetest.is_creative_enabled(placer:get_player_name()) then itemstack:set_name("mcl_buckets:bucket_empty") end From 1fcedd13757ef11e5785772cff07f0061e6eb402 Mon Sep 17 00:00:00 2001 From: cora Date: Sat, 26 Nov 2022 02:21:08 +0100 Subject: [PATCH 11/16] Fix fishbucket _on_dispense --- mods/ITEMS/mcl_buckets/fishbuckets.lua | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/fishbuckets.lua b/mods/ITEMS/mcl_buckets/fishbuckets.lua index b1de5e13e..be8e24aee 100644 --- a/mods/ITEMS/mcl_buckets/fishbuckets.lua +++ b/mods/ITEMS/mcl_buckets/fishbuckets.lua @@ -28,7 +28,7 @@ local function on_place_fish(itemstack, placer, pointed_thing) water = n.name end minetest.set_node(pos,{name = water}) - if not minetest.is_creative_enabled(placer:get_player_name()) then + if not placer or minetest.is_creative_enabled(placer:get_player_name()) then itemstack:set_name("mcl_buckets:bucket_empty") end end @@ -49,16 +49,9 @@ for techname, fishname in pairs(fish_names) do on_place = on_place_fish, on_secondary_use = on_place_fish, _on_dispense = function(stack, pos, droppos, dropnode, dropdir) - local buildable = registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal" + local buildable = minetest.registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal" if not buildable then return stack end - local result, take_bucket = get_extra_check(def.extra_check, droppos, nil) - if result then -- Fail placement of liquid if result is false - place_liquid(droppos, get_node_place(def.source_place, droppos)) - end - if take_bucket then - stack:set_name("mcl_buckets:bucket_empty") - end - return stack + return on_place_fish(stack, nil, {above=droppos}) end, }) From e134cc5e65226640659abdd3a52e9220cad5299d Mon Sep 17 00:00:00 2001 From: cora Date: Sat, 26 Nov 2022 02:25:02 +0100 Subject: [PATCH 12/16] make it possible to place fishbucket in flowing riverwater --- mods/ITEMS/mcl_buckets/fishbuckets.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_buckets/fishbuckets.lua b/mods/ITEMS/mcl_buckets/fishbuckets.lua index be8e24aee..1d9fbf496 100644 --- a/mods/ITEMS/mcl_buckets/fishbuckets.lua +++ b/mods/ITEMS/mcl_buckets/fishbuckets.lua @@ -26,8 +26,12 @@ local function on_place_fish(itemstack, placer, pointed_thing) local water = "mcl_core:water_source" if n.name == "mclx_core:river_water_source" then water = n.name + elseif n.name == "mclx_core:river_water_flowing" then + water = nil + end + if water then + minetest.set_node(pos,{name = water}) end - minetest.set_node(pos,{name = water}) if not placer or minetest.is_creative_enabled(placer:get_player_name()) then itemstack:set_name("mcl_buckets:bucket_empty") end From 66322a873ba6717479ad0b4fe50dc9dec6537e4e Mon Sep 17 00:00:00 2001 From: cora Date: Sat, 26 Nov 2022 04:10:52 +0100 Subject: [PATCH 13/16] Fix infinite fishbucket placement in survival/creative --- mods/ITEMS/mcl_buckets/fishbuckets.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_buckets/fishbuckets.lua b/mods/ITEMS/mcl_buckets/fishbuckets.lua index 1d9fbf496..d9bb5a2c5 100644 --- a/mods/ITEMS/mcl_buckets/fishbuckets.lua +++ b/mods/ITEMS/mcl_buckets/fishbuckets.lua @@ -32,7 +32,7 @@ local function on_place_fish(itemstack, placer, pointed_thing) if water then minetest.set_node(pos,{name = water}) end - if not placer or minetest.is_creative_enabled(placer:get_player_name()) then + if not placer or not minetest.is_creative_enabled(placer:get_player_name()) then itemstack:set_name("mcl_buckets:bucket_empty") end end From f14bfdc0cda0ee9770887d34e169ecf4452733ae Mon Sep 17 00:00:00 2001 From: cora Date: Sat, 26 Nov 2022 04:12:56 +0100 Subject: [PATCH 14/16] Clear item meta when turning fishbucket to empty bucket before it simply set a different itemstring, now it creates a whole new itemstack --- mods/ITEMS/mcl_buckets/fishbuckets.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_buckets/fishbuckets.lua b/mods/ITEMS/mcl_buckets/fishbuckets.lua index d9bb5a2c5..f011a9adf 100644 --- a/mods/ITEMS/mcl_buckets/fishbuckets.lua +++ b/mods/ITEMS/mcl_buckets/fishbuckets.lua @@ -33,7 +33,7 @@ local function on_place_fish(itemstack, placer, pointed_thing) minetest.set_node(pos,{name = water}) end if not placer or not minetest.is_creative_enabled(placer:get_player_name()) then - itemstack:set_name("mcl_buckets:bucket_empty") + itemstack = ItemStack("mcl_buckets:bucket_empty") end end end From efdd22d69fd377a69ac1b7fee0dd3e5c2ef0660a Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 27 Nov 2022 00:17:13 +0100 Subject: [PATCH 15/16] Fix fishbuckets placing water in the nether --- mods/ITEMS/mcl_buckets/fishbuckets.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/fishbuckets.lua b/mods/ITEMS/mcl_buckets/fishbuckets.lua index f011a9adf..aecd177ce 100644 --- a/mods/ITEMS/mcl_buckets/fishbuckets.lua +++ b/mods/ITEMS/mcl_buckets/fishbuckets.lua @@ -29,6 +29,10 @@ local function on_place_fish(itemstack, placer, pointed_thing) elseif n.name == "mclx_core:river_water_flowing" then water = nil end + if mcl_worlds.pos_to_dimension(pos) == "nether" then + water = nil + minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true) + end if water then minetest.set_node(pos,{name = water}) end @@ -53,8 +57,6 @@ for techname, fishname in pairs(fish_names) do on_place = on_place_fish, on_secondary_use = on_place_fish, _on_dispense = function(stack, pos, droppos, dropnode, dropdir) - local buildable = minetest.registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal" - if not buildable then return stack end return on_place_fish(stack, nil, {above=droppos}) end, }) From 927eff691c4a7629fb627aab8f960da8dd7fa472 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 27 Nov 2022 04:02:34 +0100 Subject: [PATCH 16/16] Fix node on_rightclick with fishbucket --- mods/ITEMS/mcl_buckets/fishbuckets.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mods/ITEMS/mcl_buckets/fishbuckets.lua b/mods/ITEMS/mcl_buckets/fishbuckets.lua index aecd177ce..9eb966084 100644 --- a/mods/ITEMS/mcl_buckets/fishbuckets.lua +++ b/mods/ITEMS/mcl_buckets/fishbuckets.lua @@ -12,6 +12,12 @@ local fish_names = { local fishbucket_prefix = "mcl_buckets:bucket_" local function on_place_fish(itemstack, placer, pointed_thing) + + local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing) + if new_stack then + return new_stack + end + local pos = pointed_thing.above or pointed_thing.under if not pos then return end local n = minetest.get_node_or_nil(pos)