forked from VoxeLibre/VoxeLibre
Fix rail movement regressions
This commit is contained in:
parent
1515a9ecbd
commit
7120365652
|
@ -296,19 +296,19 @@ function mcl_minecarts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
|
|||
|
||||
dir = node_def._mcl_minecarts.get_next_dir(pos, dir, node)
|
||||
|
||||
-- Handle going downhill
|
||||
if is_ahead_slope(pos,dir) then
|
||||
dir = vector.offset(dir,0,-1,0)
|
||||
end
|
||||
|
||||
-- Handle reversing if there is a solid block in the next position
|
||||
local next_pos = vector.add(pos, dir)
|
||||
local next_node = minetest.get_node(next_pos)
|
||||
local node_def = minetest.registered_nodes[next_node.name]
|
||||
if node_def and node_def.groups and ( node_def.groups.solid or node_def.groups.stair ) then
|
||||
-- Reverse the direction without giving -0 members
|
||||
return vector.direction(next_pos, pos)
|
||||
else
|
||||
return dir
|
||||
dir = vector.direction(next_pos, pos)
|
||||
end
|
||||
|
||||
-- Handle going downhill
|
||||
if is_ahead_slope(pos,dir) then
|
||||
dir = vector.offset(dir,0,-1,0)
|
||||
end
|
||||
|
||||
return dir
|
||||
end
|
||||
|
|
|
@ -33,6 +33,8 @@ end
|
|||
|
||||
--- Rail direction Handleres
|
||||
local function rail_dir_straight(pos, dir, node)
|
||||
dir = vector.new(dir.x, 0, dir.z)
|
||||
|
||||
if node.param2 == 0 or node.param2 == 2 then
|
||||
if vector.equals(dir, north) then
|
||||
return north
|
||||
|
@ -59,6 +61,8 @@ local function rail_dir_sloped(pos, dir, node)
|
|||
end
|
||||
end
|
||||
local function rail_dir_curve(pos, dir, node)
|
||||
dir = vector.new(dir.x, 0, dir.z)
|
||||
|
||||
if node.param2 == 0 then -- north
|
||||
-- South and East
|
||||
if vector.equals(dir, south) then return south end
|
||||
|
@ -86,10 +90,14 @@ local function rail_dir_curve(pos, dir, node)
|
|||
end
|
||||
end
|
||||
local function rail_dir_tee(pos, dir, node)
|
||||
dir = vector.new(dir.x, 0, dir.z)
|
||||
|
||||
minetest.log("warning","TODO: implement rail_dir_tee()")
|
||||
return north
|
||||
end
|
||||
local function rail_dir_cross(pos, dir, node)
|
||||
dir = vector.new(dir.x, 0, dir.z)
|
||||
|
||||
-- Always continue in the same direction. No direction changes allowed
|
||||
return dir
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue