From 5093f31f28a248150ac4fa7a45647f4af6bf97b0 Mon Sep 17 00:00:00 2001 From: anarquimico Date: Thu, 2 Mar 2023 09:20:00 -0300 Subject: [PATCH] Performance improvement --- mods/ENTITIES/mobs_mc/enderman.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/enderman.lua b/mods/ENTITIES/mobs_mc/enderman.lua index 8ddcabd9c..f5aacd667 100644 --- a/mods/ENTITIES/mobs_mc/enderman.lua +++ b/mods/ENTITIES/mobs_mc/enderman.lua @@ -447,14 +447,16 @@ mcl_mobs.register_mob("mobs_mc:enderman", { -- ATTACK ENDERMITE local enderpos = self.object:get_pos() - local mobsnear = minetest.get_objects_inside_radius(enderpos, 64) - for n=1, #mobsnear do - local mob = mobsnear[n] - if mob then - local entity = mob:get_luaentity() - if entity and entity.name == "mobs_mc:endermite" then - self.state = 'attack' - self.attack = mob + if math.random(1,20) == 1 then + local mobsnear = minetest.get_objects_inside_radius(enderpos, 64) + for n=1, #mobsnear do + local mob = mobsnear[n] + if mob then + local entity = mob:get_luaentity() + if entity and entity.name == "mobs_mc:endermite" then + self.state = 'attack' + self.attack = mob + end end end end