From 6ae597c97fb2bfade939d80af8bab7ad337f0334 Mon Sep 17 00:00:00 2001 From: codiac Date: Sat, 12 Aug 2023 14:01:26 +1000 Subject: [PATCH 1/4] This changes mob floating so they stay inside the top water node instead of standing on it. The head of the mod should still be above water. Changes drowning so that mobs will not drown in one block of water. They will drown in 2 or more blocks of water. Does not appear to affect them getting out of deep water :( But they do seem to die somewhat faster when they stay in deep water. --- mods/ENTITIES/mcl_mobs/physics.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index e1b23d78a..e49da2633 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -675,6 +675,9 @@ function mob_class:do_env_damage() self.standing_in = node_ok(pos, "air").name self.standing_on = node_ok(pos2, "air").name + local pos3 = {x=pos.x, y=pos.y+1, z=pos.z} + self.standing_under = node_ok(pos3, "air").name + -- don't fall when on ignore, just stand still if self.standing_in == "ignore" then self.object:set_velocity({x = 0, y = 0, z = 0}) @@ -682,6 +685,7 @@ function mob_class:do_env_damage() local nodef = minetest.registered_nodes[self.standing_in] local nodef2 = minetest.registered_nodes[self.standing_on] + local nodef3 = minetest.registered_nodes[self.standing_under] -- rain if self.rain_damage > 0 then @@ -761,7 +765,7 @@ function mob_class:do_env_damage() if minetest.get_item_group(self.standing_in, "water") == 0 then drowning = true end - elseif nodef.drowning > 0 then + elseif nodef.drowning > 0 and nodef3.drowning > 0 then drowning = true end @@ -939,7 +943,7 @@ function mob_class:falling(pos) -- in water then float up if registered_node.groups.water then - if acc and self.floats == 1 then + if acc and self.floats == 1 and minetest.registered_nodes[node_ok(vector.offset(pos,0,self.collisionbox[5],0)).name].groups.water then self.object:set_acceleration(vector.new(0, -self.fall_speed / (math.max(1, v.y) ^ 2), 0)) end else From 898a183ccdd7d267a93d2462f79a609180dad068 Mon Sep 17 00:00:00 2001 From: cora Date: Sat, 12 Aug 2023 08:36:24 +0200 Subject: [PATCH 2/4] Prevent floating mobs from drowning all the time Less dieing for mobs in deep water. --- mods/ENTITIES/mcl_mobs/physics.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index e49da2633..32ebc75cd 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -943,7 +943,7 @@ function mob_class:falling(pos) -- in water then float up if registered_node.groups.water then - if acc and self.floats == 1 and minetest.registered_nodes[node_ok(vector.offset(pos,0,self.collisionbox[5],0)).name].groups.water then + if acc and minetest.registered_nodes[node_ok(vector.offset(pos,0,self.collisionbox[5] -0.25,0)).name].groups.water then self.object:set_acceleration(vector.new(0, -self.fall_speed / (math.max(1, v.y) ^ 2), 0)) end else From 034382c883690dd3c22f6869494bfcdf5c30ea6f Mon Sep 17 00:00:00 2001 From: codiac Date: Sun, 13 Aug 2023 12:14:52 +1000 Subject: [PATCH 3/4] Fix float check :( --- mods/ENTITIES/mcl_mobs/physics.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index 32ebc75cd..0f3334367 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -943,7 +943,7 @@ function mob_class:falling(pos) -- in water then float up if registered_node.groups.water then - if acc and minetest.registered_nodes[node_ok(vector.offset(pos,0,self.collisionbox[5] -0.25,0)).name].groups.water then + if acc and self.floats == 1 minetest.registered_nodes[node_ok(vector.offset(pos,0,self.collisionbox[5] -0.25,0)).name].groups.water then self.object:set_acceleration(vector.new(0, -self.fall_speed / (math.max(1, v.y) ^ 2), 0)) end else From 0d16acdd423776deb955beb21e904e267f9611bf Mon Sep 17 00:00:00 2001 From: codiac Date: Mon, 14 Aug 2023 10:48:27 +1000 Subject: [PATCH 4/4] Use a vector and fix the merge fail >_< --- mods/ENTITIES/mcl_mobs/physics.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index 0f3334367..341e28984 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -675,7 +675,7 @@ function mob_class:do_env_damage() self.standing_in = node_ok(pos, "air").name self.standing_on = node_ok(pos2, "air").name - local pos3 = {x=pos.x, y=pos.y+1, z=pos.z} + local pos3 = vector.offset(pos, 0, 1, 0) self.standing_under = node_ok(pos3, "air").name -- don't fall when on ignore, just stand still @@ -943,7 +943,7 @@ function mob_class:falling(pos) -- in water then float up if registered_node.groups.water then - if acc and self.floats == 1 minetest.registered_nodes[node_ok(vector.offset(pos,0,self.collisionbox[5] -0.25,0)).name].groups.water then + if acc and self.floats == 1 and minetest.registered_nodes[node_ok(vector.offset(pos,0,self.collisionbox[5] -0.25,0)).name].groups.water then self.object:set_acceleration(vector.new(0, -self.fall_speed / (math.max(1, v.y) ^ 2), 0)) end else