From 847631202e822692ad29d7c72f7cac8690315a12 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Fri, 12 Apr 2024 20:47:47 +0000 Subject: [PATCH] Fix players repelling carts with new player metadata system --- mods/ENTITIES/mcl_minecarts/carts.lua | 12 ++++++------ mods/ENTITIES/mcl_minecarts/carts/minecart.lua | 4 ++-- mods/ENTITIES/mcl_minecarts/movement.lua | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mods/ENTITIES/mcl_minecarts/carts.lua b/mods/ENTITIES/mcl_minecarts/carts.lua index f6c23a6f5..9e6593d06 100644 --- a/mods/ENTITIES/mcl_minecarts/carts.lua +++ b/mods/ENTITIES/mcl_minecarts/carts.lua @@ -42,8 +42,8 @@ local function detach_driver(self) -- Update cart informatino self._driver = nil self._start_pos = nil - local meta = mcl_playerinfo.get_mod_meta(driver_name, modname) - meta.attached_to = nil + local player_meta = mcl_playerinfo.get_mod_meta(driver_name, modname) + player_meta.attached_to = nil -- Detatch the player object from the minecart local player = minetest.get_player_by_name(driver_name) @@ -267,7 +267,7 @@ function mod.kill_cart(staticdata, killer) if staticdata.attached_at then handle_cart_leave(self, staticdata.attached_at, staticdata.dir ) else - mcl_log("TODO: handle detatched minecart death") + --mcl_log("TODO: handle detatched minecart death") end -- Handle entity-related items @@ -527,7 +527,7 @@ local function respawn_cart(cart) end if not distance or distance > 90 then return end - print("Respawning cart #"..cart.uuid.." at "..tostring(pos)..",distance="..distance..",node="..minetest.get_node(pos).name) + mcl_log("Respawning cart #"..cart.uuid.." at "..tostring(pos)..",distance="..distance..",node="..minetest.get_node(pos).name) -- Update sequence so that old cart entities get removed cart.seq = (cart.seq or 1) + 1 @@ -613,8 +613,8 @@ end) minetest.register_on_joinplayer(function(player) local player_name = player:get_player_name() - local meta = mcl_playerinfo.get_mod_meta(player_name, modname) - local cart_uuid = meta.attached_to + local player_meta = mcl_playerinfo.get_mod_meta(player_name, modname) + local cart_uuid = player_meta.attached_to if cart_uuid then local cartdata = get_cart_data(cart_uuid) diff --git a/mods/ENTITIES/mcl_minecarts/carts/minecart.lua b/mods/ENTITIES/mcl_minecarts/carts/minecart.lua index 7f36fbb07..693767b1d 100644 --- a/mods/ENTITIES/mcl_minecarts/carts/minecart.lua +++ b/mods/ENTITIES/mcl_minecarts/carts/minecart.lua @@ -30,8 +30,8 @@ function mod.attach_driver(cart, player) cart._start_pos = cart.object:get_pos() -- Keep track of player attachment - local meta = mcl_playerinfo.get_mod_meta(player_name, modname) - meta.attached_to = cart._uuid + local player_meta = mcl_playerinfo.get_mod_meta(player_name, modname) + player_meta.attached_to = cart._uuid staticdata.last_player = player_name -- Update player information diff --git a/mods/ENTITIES/mcl_minecarts/movement.lua b/mods/ENTITIES/mcl_minecarts/movement.lua index be9a0ca6c..2499bddc4 100644 --- a/mods/ENTITIES/mcl_minecarts/movement.lua +++ b/mods/ENTITIES/mcl_minecarts/movement.lua @@ -185,8 +185,8 @@ local function vector_away_from_players(cart, staticdata) if not player_name or player_name == "" then return false end -- Don't repel away from players in minecarts - local playerinfo = mcl_playerinfo[player_name] - if playerinfo and playerinfo.attached_to then return false end + local player_meta = mcl_playerinfo.get_mod_meta(player_name, modname) + if player_meta.attached_to then return false end return true end