Fix a couple of crashes (TNT minecart trying to update orientation after exploding, trying to punch/push a minecart not on track)
This commit is contained in:
parent
3ac122e2d7
commit
ad6a9c7c64
|
@ -391,6 +391,8 @@ function mod.update_cart_orientation(self)
|
||||||
|
|
||||||
-- Check if the rotation is a 180 flip and don't change if so
|
-- Check if the rotation is a 180 flip and don't change if so
|
||||||
local rot = self.object:get_rotation()
|
local rot = self.object:get_rotation()
|
||||||
|
if not rot then return end
|
||||||
|
|
||||||
local diff = math.abs((rot_y - ( rot.y + pi ) % _2_pi) )
|
local diff = math.abs((rot_y - ( rot.y + pi ) % _2_pi) )
|
||||||
if diff < 0.001 or diff > _2_pi - 0.001 then
|
if diff < 0.001 or diff > _2_pi - 0.001 then
|
||||||
-- Update rotation adjust and recalculate the rotation
|
-- Update rotation adjust and recalculate the rotation
|
||||||
|
@ -431,6 +433,8 @@ function mod.reverse_cart_direction(staticdata)
|
||||||
|
|
||||||
-- Complete moving thru this block into the next, reverse direction, and put us back at the same position we were at
|
-- Complete moving thru this block into the next, reverse direction, and put us back at the same position we were at
|
||||||
local next_dir = -staticdata.dir
|
local next_dir = -staticdata.dir
|
||||||
|
if not staticdata.connected_at then return end
|
||||||
|
|
||||||
staticdata.connected_at = staticdata.connected_at + staticdata.dir
|
staticdata.connected_at = staticdata.connected_at + staticdata.dir
|
||||||
staticdata.distance = 1 - (staticdata.distance or 0)
|
staticdata.distance = 1 - (staticdata.distance or 0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue