[mineclone5] [mcl_mobs] Avoid some crashes in `mob_functions/ai/lua`, @jordan4ibanez feel free to revert
parent
073e7b81f8
commit
7c9d9b1650
|
@ -171,7 +171,9 @@ local land_state_execution = function(self,dtime)
|
||||||
|
|
||||||
--make slow falling mobs fall slow
|
--make slow falling mobs fall slow
|
||||||
if self.fall_slow then
|
if self.fall_slow then
|
||||||
if self.object:get_velocity().y < 0 then
|
local velocity = self.object:get_velocity()
|
||||||
|
if velocity then
|
||||||
|
if velocity.y < 0 then
|
||||||
--lua is acting really weird so we have to help it
|
--lua is acting really weird so we have to help it
|
||||||
if round2(self.object:get_acceleration().y, 1) == -self.gravity then
|
if round2(self.object:get_acceleration().y, 1) == -self.gravity then
|
||||||
self.object:set_acceleration(vector_new(0,0,0))
|
self.object:set_acceleration(vector_new(0,0,0))
|
||||||
|
@ -183,6 +185,7 @@ local land_state_execution = function(self,dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if self.state == "stand" then
|
if self.state == "stand" then
|
||||||
|
|
||||||
|
@ -371,9 +374,12 @@ local land_state_execution = function(self,dtime)
|
||||||
|
|
||||||
if float_now then
|
if float_now then
|
||||||
mobs.float(self)
|
mobs.float(self)
|
||||||
elseif self.object:get_acceleration().y == 0 then
|
else
|
||||||
|
local acceleration = self.object:get_acceleration()
|
||||||
|
if acceleration and acceleration.y == 0 then
|
||||||
self.object:set_acceleration(vector_new(0,-self.gravity,0))
|
self.object:set_acceleration(vector_new(0,-self.gravity,0))
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -894,7 +900,7 @@ mobs.mob_step = function(self, dtime)
|
||||||
|
|
||||||
pos.y = pos.y + self.eye_height
|
pos.y = pos.y + self.eye_height
|
||||||
|
|
||||||
local node = minetest.get_node(pos).name
|
local node = minetest_get_node(pos).name
|
||||||
|
|
||||||
if minetest_get_item_group(node, "water") ~= 0 then
|
if minetest_get_item_group(node, "water") ~= 0 then
|
||||||
self.breath = self.breath - dtime
|
self.breath = self.breath - dtime
|
||||||
|
@ -1106,7 +1112,7 @@ mobs.mob_step = function(self, dtime)
|
||||||
if not self.ignores_cobwebs then
|
if not self.ignores_cobwebs then
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
local node = minetest_get_node(pos).name
|
local node = pos and minetest_get_node(pos).name
|
||||||
|
|
||||||
if node == "mcl_core:cobweb" then
|
if node == "mcl_core:cobweb" then
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue