From 51a1dfee56f2d939b95ddbbd93e2ebacdcd7fd08 Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Mon, 6 Feb 2023 04:35:35 +0000 Subject: [PATCH] Fix game crashes --- mods/ENTITIES/mcl_mobs/effects.lua | 15 +++++++++++++-- mods/ENTITIES/mcl_mobs/physics.lua | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/effects.lua b/mods/ENTITIES/mcl_mobs/effects.lua index d4b071f93..a8b761d47 100644 --- a/mods/ENTITIES/mcl_mobs/effects.lua +++ b/mods/ENTITIES/mcl_mobs/effects.lua @@ -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 active_particlespawners = {} 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 +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 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) end + + function mob_class:set_animation_speed() local v = self.object:get_velocity() if v then @@ -400,7 +411,7 @@ function mob_class:set_animation_speed() end end --set_speed - if self.acc then + if validate_vector(self.acc) then self.object:add_velocity(self.acc) end end diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index d4d3c836d..797bb4b7e 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -311,6 +311,8 @@ end function mob_class:set_yaw(yaw, delay, dtime) 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 self._turn_to = yaw end