mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2025-01-09 00:29:33 +01:00
Prevent players getting in the same cart as a mob, don't allow mobs already in a cart to be moved to another one
This commit is contained in:
parent
bef17e5401
commit
bf9ad1919e
1 changed files with 5 additions and 1 deletions
|
@ -22,9 +22,13 @@ function mod.attach_driver(cart, player)
|
|||
-- Make sure we have a player
|
||||
if not player or not player:is_player() then return end
|
||||
|
||||
-- Prevent more than one player getting in the cart
|
||||
local player_name = player:get_player_name()
|
||||
if cart._driver or player:get_player_control().sneak then return end
|
||||
|
||||
-- Prevent getting into a cart that already has a passenger
|
||||
if cart._passenger then return end
|
||||
|
||||
-- Update cart information
|
||||
cart._driver = player_name
|
||||
cart._start_pos = cart.object:get_pos()
|
||||
|
@ -82,7 +86,7 @@ mod.register_minecart({
|
|||
local mobsnear = minetest.get_objects_inside_radius(self.object:get_pos(), 1.3)
|
||||
for n=1, #mobsnear do
|
||||
local mob = mobsnear[n]
|
||||
if mob then
|
||||
if mob and not mob:get_attach() then
|
||||
local entity = mob:get_luaentity()
|
||||
if entity and entity.is_mob then
|
||||
self._passenger = entity
|
||||
|
|
Loading…
Reference in a new issue