mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-01-11 10:20:21 +01:00
fix velocity and nil check
This commit is contained in:
parent
3a17c471ae
commit
351fce8ee8
9
api.lua
9
api.lua
@ -6,7 +6,7 @@ local use_cmi = minetest.global_exists("cmi")
|
|||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20200516",
|
version = "20200519",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||||
}
|
}
|
||||||
@ -982,7 +982,7 @@ function mob_class:do_env_damage()
|
|||||||
-- halt mob if standing inside ignore node
|
-- halt mob if standing inside ignore node
|
||||||
if self.standing_in == "ignore" then
|
if self.standing_in == "ignore" then
|
||||||
|
|
||||||
self.object:set_velocity(0)
|
self.object:set_velocity({x = 0, y = 0, z = 0})
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -1438,11 +1438,14 @@ end
|
|||||||
-- find and replace what mob is looking for (grass, wheat etc.)
|
-- find and replace what mob is looking for (grass, wheat etc.)
|
||||||
function mob_class:replace(pos)
|
function mob_class:replace(pos)
|
||||||
|
|
||||||
|
local vel = self.object:get_velocity()
|
||||||
|
if not vel then return end
|
||||||
|
|
||||||
if not mobs_griefing
|
if not mobs_griefing
|
||||||
or not self.replace_rate
|
or not self.replace_rate
|
||||||
or not self.replace_what
|
or not self.replace_what
|
||||||
or self.child == true
|
or self.child == true
|
||||||
or self.object:get_velocity().y ~= 0
|
or vel.y ~= 0
|
||||||
or random(1, self.replace_rate) > 1 then
|
or random(1, self.replace_rate) > 1 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user