From efe190e23c909dad55b58ad0035d540652ab319c Mon Sep 17 00:00:00 2001 From: teknomunk Date: Sat, 6 Apr 2024 05:56:21 +0000 Subject: [PATCH] Fix rail movement regressions --- mods/ENTITIES/mcl_minecarts/functions.lua | 16 ++++++++-------- mods/ENTITIES/mcl_minecarts/rails.lua | 8 ++++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/mods/ENTITIES/mcl_minecarts/functions.lua b/mods/ENTITIES/mcl_minecarts/functions.lua index 2ed625e02..a991793be 100644 --- a/mods/ENTITIES/mcl_minecarts/functions.lua +++ b/mods/ENTITIES/mcl_minecarts/functions.lua @@ -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 diff --git a/mods/ENTITIES/mcl_minecarts/rails.lua b/mods/ENTITIES/mcl_minecarts/rails.lua index f5ebaa40e..45498c89c 100644 --- a/mods/ENTITIES/mcl_minecarts/rails.lua +++ b/mods/ENTITIES/mcl_minecarts/rails.lua @@ -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