From f817fe7f729c9a0b4eb67967531af0c5e79eed88 Mon Sep 17 00:00:00 2001 From: anarquimico Date: Sun, 19 Mar 2023 19:15:05 -0300 Subject: [PATCH] Fix performance issues and better check for mobs death --- mods/ENTITIES/mcl_minecarts/init.lua | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/mods/ENTITIES/mcl_minecarts/init.lua b/mods/ENTITIES/mcl_minecarts/init.lua index a951ae4b2..8d4a280a1 100644 --- a/mods/ENTITIES/mcl_minecarts/init.lua +++ b/mods/ENTITIES/mcl_minecarts/init.lua @@ -214,7 +214,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o end -- 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 local mobsnear = minetest.get_objects_inside_radius(self.object:get_pos(), 1.3) for n=1, #mobsnear do @@ -222,7 +222,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o if mob then local entity = mob:get_luaentity() 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}) break end @@ -231,13 +231,9 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o end -- Make room in the minecart after the mob dies elseif self._passenger then - local mobinside = minetest.get_objects_inside_radius(self.object:get_pos(), 1) - for n=1, #mobinside do - local mob = mobinside[n]:get_luaentity() - if not mob or mob.is_mob == false then - self._passenger = nil - break - end + dead = self._passenger:check_for_death() + if dead == true then + self._passenger = nil end end