mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-13 07:13:21 +01:00
Fix rail movement regressions
This commit is contained in:
parent
e6664de6e7
commit
6d9cae1034
2 changed files with 16 additions and 8 deletions
|
@ -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)
|
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
|
-- 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)
|
||||||
local next_node = minetest.get_node(next_pos)
|
local next_node = minetest.get_node(next_pos)
|
||||||
local node_def = minetest.registered_nodes[next_node.name]
|
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
|
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
|
-- Reverse the direction without giving -0 members
|
||||||
return vector.direction(next_pos, pos)
|
dir = vector.direction(next_pos, pos)
|
||||||
else
|
|
||||||
return dir
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Handle going downhill
|
||||||
|
if is_ahead_slope(pos,dir) then
|
||||||
|
dir = vector.offset(dir,0,-1,0)
|
||||||
|
end
|
||||||
|
|
||||||
|
return dir
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,6 +33,8 @@ end
|
||||||
|
|
||||||
--- Rail direction Handleres
|
--- Rail direction Handleres
|
||||||
local function rail_dir_straight(pos, dir, node)
|
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 node.param2 == 0 or node.param2 == 2 then
|
||||||
if vector.equals(dir, north) then
|
if vector.equals(dir, north) then
|
||||||
return north
|
return north
|
||||||
|
@ -59,6 +61,8 @@ local function rail_dir_sloped(pos, dir, node)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function rail_dir_curve(pos, dir, node)
|
local function rail_dir_curve(pos, dir, node)
|
||||||
|
dir = vector.new(dir.x, 0, dir.z)
|
||||||
|
|
||||||
if node.param2 == 0 then -- north
|
if node.param2 == 0 then -- north
|
||||||
-- South and East
|
-- South and East
|
||||||
if vector.equals(dir, south) then return south end
|
if vector.equals(dir, south) then return south end
|
||||||
|
@ -86,10 +90,14 @@ local function rail_dir_curve(pos, dir, node)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function rail_dir_tee(pos, dir, node)
|
local function rail_dir_tee(pos, dir, node)
|
||||||
|
dir = vector.new(dir.x, 0, dir.z)
|
||||||
|
|
||||||
minetest.log("warning","TODO: implement rail_dir_tee()")
|
minetest.log("warning","TODO: implement rail_dir_tee()")
|
||||||
return north
|
return north
|
||||||
end
|
end
|
||||||
local function rail_dir_cross(pos, dir, node)
|
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
|
-- Always continue in the same direction. No direction changes allowed
|
||||||
return dir
|
return dir
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue