Registered detach function and used `mcl_player.detach_player` for detach

This commit is contained in:
WillConker 2024-06-06 14:53:41 +00:00
parent 8b6c2800a2
commit 99c0e12418
1 changed files with 9 additions and 1 deletions

View File

@ -34,6 +34,13 @@ local function detach_driver(self)
end
end
function mcl_minecarts.quick_detach_player(player, minecart)
-- called in mcl_player
-- is below line necessary?
if not player == minecart._driver then return end
detach_driver(minecart)
end
local function activate_tnt_minecart(self, timer)
if self._boomtimer then
return
@ -646,7 +653,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o
if update.pos then
self.object:set_pos(pos)
end
-- stopped on "mcl_minecarts:golden_rail_on"
if vector.equals(vel, {x=0, y=0, z=0}) and restart_pos then
local dir = mcl_minecarts:get_start_direction(restart_pos)
@ -811,6 +818,7 @@ register_minecart(
if self._driver and player_name == self._driver then
detach_driver(self)
elseif not self._driver then
mcl_player.detach_player(clicker)
self._driver = player_name
self._start_pos = self.object:get_pos()
mcl_player.player_attached[player_name] = true