1
0
Fork 0

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.
This commit is contained in:
codiac 2023-08-12 14:01:26 +10:00
parent e3bdedb4d5
commit 6ae597c97f
1 changed files with 6 additions and 2 deletions

View File

@ -675,6 +675,9 @@ function mob_class:do_env_damage()
self.standing_in = node_ok(pos, "air").name self.standing_in = node_ok(pos, "air").name
self.standing_on = node_ok(pos2, "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 -- don't fall when on ignore, just stand still
if self.standing_in == "ignore" then if self.standing_in == "ignore" then
self.object:set_velocity({x = 0, y = 0, z = 0}) 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 nodef = minetest.registered_nodes[self.standing_in]
local nodef2 = minetest.registered_nodes[self.standing_on] local nodef2 = minetest.registered_nodes[self.standing_on]
local nodef3 = minetest.registered_nodes[self.standing_under]
-- rain -- rain
if self.rain_damage > 0 then 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 if minetest.get_item_group(self.standing_in, "water") == 0 then
drowning = true drowning = true
end end
elseif nodef.drowning > 0 then elseif nodef.drowning > 0 and nodef3.drowning > 0 then
drowning = true drowning = true
end end
@ -939,7 +943,7 @@ function mob_class:falling(pos)
-- in water then float up -- in water then float up
if registered_node.groups.water then 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)) self.object:set_acceleration(vector.new(0, -self.fall_speed / (math.max(1, v.y) ^ 2), 0))
end end
else else