forked from Mineclonia/Mineclonia
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:
parent
37828b27a0
commit
47ef53db56
|
@ -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
|
cart.on_activate_by_rail = on_activate_by_rail
|
||||||
|
|
||||||
function cart:on_step(dtime)
|
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
|
if self._pickup_inhibit_timer > 0 then
|
||||||
self._pickup_inhibit_timer = self._pickup_inhibit_timer - dtime
|
self._pickup_inhibit_timer = self._pickup_inhibit_timer - dtime
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue