Merge pull request 'Fix crash when getting attacked by mob while in boat' (#2778) from fix_boat_mob_crash into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/2778
This commit is contained in:
cora 2022-10-14 23:59:00 +00:00
commit 210496b615

View file

@ -3991,6 +3991,7 @@ local mob_step = function(self, dtime)
if self._locked_object:is_player() then if self._locked_object:is_player() then
_locked_object_eye_height = self._locked_object:get_properties().eye_height _locked_object_eye_height = self._locked_object:get_properties().eye_height
end end
if _locked_object_eye_height then
local self_rot = self.object:get_rotation() local self_rot = self.object:get_rotation()
if self.object:get_attach() then if self.object:get_attach() then
self_rot = self.object:get_attach():get_rotation() self_rot = self.object:get_attach():get_rotation()
@ -4014,6 +4015,7 @@ local mob_step = function(self, dtime)
mcl_util.set_bone_position(self.object,self.head_swivel, vector.new(0,self.bone_eye_height,self.horrizonatal_head_height), vector.new(((mob_pitch-oldr.x)*.3)+oldr.x, 0, -(((mob_yaw-oldr.y)*.3)+oldr.y)*3)) mcl_util.set_bone_position(self.object,self.head_swivel, vector.new(0,self.bone_eye_height,self.horrizonatal_head_height), vector.new(((mob_pitch-oldr.x)*.3)+oldr.x, 0, -(((mob_yaw-oldr.y)*.3)+oldr.y)*3))
end end
end end
end
elseif not self._locked_object and math.abs(oldr.y) > 3 and math.abs(oldr.x) < 3 then elseif not self._locked_object and math.abs(oldr.y) > 3 and math.abs(oldr.x) < 3 then
mcl_util.set_bone_position(self.object,self.head_swivel, vector.new(0,self.bone_eye_height,self.horrizonatal_head_height), vector.multiply(oldr, 0.9)) mcl_util.set_bone_position(self.object,self.head_swivel, vector.new(0,self.bone_eye_height,self.horrizonatal_head_height), vector.multiply(oldr, 0.9))
else else