mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-19 14:59:33 +01:00
Fix performance issues and better check for mobs death
This commit is contained in:
parent
d5f01e88c4
commit
f817fe7f72
1 changed files with 5 additions and 9 deletions
|
@ -214,7 +214,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Grab mob
|
-- Grab mob
|
||||||
if not self._passenger then
|
if math.random(1,20) > 15 and not self._passenger then
|
||||||
if self.name == "mcl_minecarts:minecart" then
|
if self.name == "mcl_minecarts:minecart" then
|
||||||
local mobsnear = minetest.get_objects_inside_radius(self.object:get_pos(), 1.3)
|
local mobsnear = minetest.get_objects_inside_radius(self.object:get_pos(), 1.3)
|
||||||
for n=1, #mobsnear do
|
for n=1, #mobsnear do
|
||||||
|
@ -222,7 +222,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o
|
||||||
if mob then
|
if mob then
|
||||||
local entity = mob:get_luaentity()
|
local entity = mob:get_luaentity()
|
||||||
if entity and entity.is_mob then
|
if entity and entity.is_mob then
|
||||||
self._passenger = entity.name
|
self._passenger = entity
|
||||||
mob:set_attach(self.object, "", {x=0, y=-1.75, z=0}, {x=0, y=0, z=0})
|
mob:set_attach(self.object, "", {x=0, y=-1.75, z=0}, {x=0, y=0, z=0})
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@ -231,13 +231,9 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o
|
||||||
end
|
end
|
||||||
-- Make room in the minecart after the mob dies
|
-- Make room in the minecart after the mob dies
|
||||||
elseif self._passenger then
|
elseif self._passenger then
|
||||||
local mobinside = minetest.get_objects_inside_radius(self.object:get_pos(), 1)
|
dead = self._passenger:check_for_death()
|
||||||
for n=1, #mobinside do
|
if dead == true then
|
||||||
local mob = mobinside[n]:get_luaentity()
|
|
||||||
if not mob or mob.is_mob == false then
|
|
||||||
self._passenger = nil
|
self._passenger = nil
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue