Fix vertical movement that was hitting 45 degree curve code, reset pitch on minecarts

This commit is contained in:
teknomunk 2024-11-03 07:38:54 -06:00
parent 1f83937de9
commit 5b1b75b0fc
3 changed files with 14 additions and 7 deletions

View File

@ -296,6 +296,7 @@ function DEFAULT_CART_DEF:on_step(dtime)
if staticdata.seq and self._seq < staticdata.seq then if staticdata.seq and self._seq < staticdata.seq then
--print("removing cart #"..staticdata.uuid.." with sequence number mismatch") --print("removing cart #"..staticdata.uuid.." with sequence number mismatch")
self.object:remove() self.object:remove()
self._removed = true
return return
end end

View File

@ -2,7 +2,7 @@ local vector = vector
local mod = mcl_minecarts local mod = mcl_minecarts
local table_merge = mcl_util.table_merge local table_merge = mcl_util.table_merge
function get_path(base, first, ...) local function get_path(base, first, ...)
if not first then return base end if not first then return base end
if not base then return end if not base then return end
return get_path(base[first], ...) return get_path(base[first], ...)
@ -311,11 +311,10 @@ end
local function get_rail_direction_inner(pos, dir) local function get_rail_direction_inner(pos, dir)
-- Handle new track types that have track-specific direction handler -- Handle new track types that have track-specific direction handler
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
local node_def = minetest.registered_nodes[node.name] local get_next_dir = get_path(minetest.registered_nodes,node.name,"_mcl_minecarts","get_next_dir")
local get_next_dir = get_path(node_def,"_mcl_minecarts","get_next_dir")
if not get_next_dir then return dir end if not get_next_dir then return dir end
dir = node_def._mcl_minecarts.get_next_dir(pos, dir, node) dir = get_next_dir(pos, dir, node)
-- Handle reversing if there is a solid block in the next position -- Handle reversing if there is a solid block in the next position
local next_pos = vector.add(pos, dir) local next_pos = vector.add(pos, dir)
@ -367,13 +366,15 @@ function mcl_minecarts.get_rail_direction(self, pos_, dir)
local new_dir = get_rail_direction_inner(pos, dir) local new_dir = get_rail_direction_inner(pos, dir)
if new_dir.y ~= 0 then return new_dir end
-- Check four 45 degree movement -- Check four 45 degree movement
local next_rails_dir = get_rail_direction_inner(vector.add(pos, new_dir), new_dir) local next_rails_dir = get_rail_direction_inner(vector.add(pos, new_dir), new_dir)
if vector.equals(next_rails_dir, dir) and not vector.equals(new_dir, next_rails_dir) then if dir.y == 0 and vector.equals(next_rails_dir, dir) and not vector.equals(new_dir, next_rails_dir) then
return vector.add(new_dir, next_rails_dir) return vector.add(new_dir, next_rails_dir)
else
return new_dir
end end
return new_dir
end end
function mod.update_cart_orientation(self) function mod.update_cart_orientation(self)
local staticdata = self._staticdata local staticdata = self._staticdata

View File

@ -539,6 +539,11 @@ function submod.do_detached_movement(self, dtime)
self.object:set_acceleration(accel) self.object:set_acceleration(accel)
end end
-- Reset pitch
local rot = self.object:get_rotation()
rot.y = 0
self.object:set_rotation(rot)
local away = vector_away_from_players(self, staticdata) local away = vector_away_from_players(self, staticdata)
if away then if away then
local v = self.object:get_velocity() local v = self.object:get_velocity()