Fix game crashes

This commit is contained in:
ancientmarinerdev 2023-02-06 04:35:35 +00:00 committed by Michieal
parent c3e6bbd871
commit 51a1dfee56
2 changed files with 15 additions and 2 deletions

View File

@ -1,4 +1,4 @@
local math, vector, minetest, mcl_mobs = math, vector, minetest, mcl_mobs local math, tonumber, vector, minetest, mcl_mobs = math, tonumber, vector, minetest, mcl_mobs
local mob_class = mcl_mobs.mob_class local mob_class = mcl_mobs.mob_class
local active_particlespawners = {} local active_particlespawners = {}
local disable_blood = minetest.settings:get_bool("mobs_disable_blood") local disable_blood = minetest.settings:get_bool("mobs_disable_blood")
@ -8,6 +8,15 @@ local player_transfer_distance = tonumber(minetest.settings:get("player_transfer
if player_transfer_distance == 0 then player_transfer_distance = math.huge end if player_transfer_distance == 0 then player_transfer_distance = math.huge end
local function validate_vector (vect)
if vect then
if tonumber(vect.x) and tonumber(vect.y) and tonumber(vect.z) then
return true
end
end
return false
end
-- custom particle effects -- custom particle effects
function mcl_mobs.effect(pos, amount, texture, min_size, max_size, radius, gravity, glow, go_down) function mcl_mobs.effect(pos, amount, texture, min_size, max_size, radius, gravity, glow, go_down)
@ -385,6 +394,8 @@ function mob_class:check_head_swivel(dtime)
mcl_util.set_bone_position(self.object,self.head_swivel, vector.new(0,self.bone_eye_height,self.horrizonatal_head_height), final_rotation) mcl_util.set_bone_position(self.object,self.head_swivel, vector.new(0,self.bone_eye_height,self.horrizonatal_head_height), final_rotation)
end end
function mob_class:set_animation_speed() function mob_class:set_animation_speed()
local v = self.object:get_velocity() local v = self.object:get_velocity()
if v then if v then
@ -400,7 +411,7 @@ function mob_class:set_animation_speed()
end end
end end
--set_speed --set_speed
if self.acc then if validate_vector(self.acc) then
self.object:add_velocity(self.acc) self.object:add_velocity(self.acc)
end end
end end

View File

@ -311,6 +311,8 @@ end
function mob_class:set_yaw(yaw, delay, dtime) function mob_class:set_yaw(yaw, delay, dtime)
if self.noyaw then return end if self.noyaw then return end
if not self.object:get_yaw() or not self.object:get_pos() then return end
if self.state ~= PATHFINDING then if self.state ~= PATHFINDING then
self._turn_to = yaw self._turn_to = yaw
end end