Force-detach minecart driver not attached to cart

If the driver manages to either die in a minecart or attach to some
other object, they may still be taking up space in the cart. No new
driver could enter a cart in such a situation, therefore any driver
of a cart without an attached object must be detached immediately.
This commit is contained in:
Nils Dagsson Moskopp 2021-08-01 21:25:56 +02:00
parent 37828b27a0
commit 47ef53db56
No known key found for this signature in database
GPG Key ID: A3BC671C35191080
1 changed files with 9 additions and 0 deletions

View File

@ -183,6 +183,15 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o
cart.on_activate_by_rail = on_activate_by_rail
function cart:on_step(dtime)
-- If the driver manages to either die in a minecart
-- or attach to some other object, they may still be
-- taking up space in the cart. Therefore the driver
-- must be detached if the minecart has no children.
if self._driver and
#self.object:get_children() == 0 then
detach_driver(self)
end
if self._pickup_inhibit_timer > 0 then
self._pickup_inhibit_timer = self._pickup_inhibit_timer - dtime
end