From 6ae597c97fb2bfade939d80af8bab7ad337f0334 Mon Sep 17 00:00:00 2001 From: codiac Date: Sat, 12 Aug 2023 14:01:26 +1000 Subject: [PATCH] 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