Fix players repelling carts with new player metadata system
This commit is contained in:
parent
bb30dffeb9
commit
2e2b0225c6
|
@ -42,8 +42,8 @@ local function detach_driver(self)
|
||||||
-- Update cart informatino
|
-- Update cart informatino
|
||||||
self._driver = nil
|
self._driver = nil
|
||||||
self._start_pos = nil
|
self._start_pos = nil
|
||||||
local meta = mcl_playerinfo.get_mod_meta(driver_name, modname)
|
local player_meta = mcl_playerinfo.get_mod_meta(driver_name, modname)
|
||||||
meta.attached_to = nil
|
player_meta.attached_to = nil
|
||||||
|
|
||||||
-- Detatch the player object from the minecart
|
-- Detatch the player object from the minecart
|
||||||
local player = minetest.get_player_by_name(driver_name)
|
local player = minetest.get_player_by_name(driver_name)
|
||||||
|
@ -267,7 +267,7 @@ function mod.kill_cart(staticdata, killer)
|
||||||
if staticdata.attached_at then
|
if staticdata.attached_at then
|
||||||
handle_cart_leave(self, staticdata.attached_at, staticdata.dir )
|
handle_cart_leave(self, staticdata.attached_at, staticdata.dir )
|
||||||
else
|
else
|
||||||
mcl_log("TODO: handle detatched minecart death")
|
--mcl_log("TODO: handle detatched minecart death")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Handle entity-related items
|
-- Handle entity-related items
|
||||||
|
@ -527,7 +527,7 @@ local function respawn_cart(cart)
|
||||||
end
|
end
|
||||||
if not distance or distance > 90 then return 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
|
-- Update sequence so that old cart entities get removed
|
||||||
cart.seq = (cart.seq or 1) + 1
|
cart.seq = (cart.seq or 1) + 1
|
||||||
|
@ -613,8 +613,8 @@ end)
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
local meta = mcl_playerinfo.get_mod_meta(player_name, modname)
|
local player_meta = mcl_playerinfo.get_mod_meta(player_name, modname)
|
||||||
local cart_uuid = meta.attached_to
|
local cart_uuid = player_meta.attached_to
|
||||||
if cart_uuid then
|
if cart_uuid then
|
||||||
local cartdata = get_cart_data(cart_uuid)
|
local cartdata = get_cart_data(cart_uuid)
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@ function mod.attach_driver(cart, player)
|
||||||
cart._start_pos = cart.object:get_pos()
|
cart._start_pos = cart.object:get_pos()
|
||||||
|
|
||||||
-- Keep track of player attachment
|
-- Keep track of player attachment
|
||||||
local meta = mcl_playerinfo.get_mod_meta(player_name, modname)
|
local player_meta = mcl_playerinfo.get_mod_meta(player_name, modname)
|
||||||
meta.attached_to = cart._uuid
|
player_meta.attached_to = cart._uuid
|
||||||
staticdata.last_player = player_name
|
staticdata.last_player = player_name
|
||||||
|
|
||||||
-- Update player information
|
-- Update player information
|
||||||
|
|
|
@ -185,8 +185,8 @@ local function vector_away_from_players(cart, staticdata)
|
||||||
if not player_name or player_name == "" then return false end
|
if not player_name or player_name == "" then return false end
|
||||||
|
|
||||||
-- Don't repel away from players in minecarts
|
-- Don't repel away from players in minecarts
|
||||||
local playerinfo = mcl_playerinfo[player_name]
|
local player_meta = mcl_playerinfo.get_mod_meta(player_name, modname)
|
||||||
if playerinfo and playerinfo.attached_to then return false end
|
if player_meta.attached_to then return false end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue