Make sure carts that collide move in the same direction the colliding cart was

This commit is contained in:
teknomunk 2024-04-06 14:23:59 +00:00
parent bacc8bdf64
commit 3ca5bd0dff
1 changed files with 7 additions and 1 deletions

View File

@ -116,7 +116,10 @@ local function handle_cart_leave(self, pos, next_dir)
handle_cart_enter_exit(self, pos, next_dir, "on_leave" )
end
local function handle_cart_collision(cart1, pos, next_dir)
local function handle_cart_collision(cart1, prev_pos, next_dir)
-- Look ahead one block
local pos = vector.add(prev_pos, next_dir)
local meta = minetest.get_meta(pos)
local carts = minetest.deserialize(meta:get_string("_mcl_minecarts_carts")) or {}
local cart_uuid = nil
@ -159,6 +162,9 @@ local function handle_cart_collision(cart1, pos, next_dir)
cart1_staticdata.velocity = v1
cart2_staticdata.velocity = v2
-- Force the other cart to move the same direction this one was
cart2_staticdata.dir = cart1_staticdata.dir
end
local function handle_cart_node_watches(self, dtime)