From 87f50d64235fe4e8a4929463e27deb28281d15e3 Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 23 May 2022 16:50:33 +0200 Subject: [PATCH] entity cramming: clean up check logic --- mods/ENTITIES/mcl_mobs/api.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index b21707065..959c59ff1 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -2975,20 +2975,21 @@ local cramming_damage = 3 local function check_entity_cramming(self) local p = self.object:get_pos() local oo = minetest.get_objects_inside_radius(p,1) - local clear = false - if #oo < entity_cramming_max then clear = true end + local clear = #oo < entity_cramming_max local ncram = {} for _,o in pairs(oo) do local l = o:get_luaentity() - if l and clear then - l.cram = nil - elseif l and l.cram == nil and not self.child then - table.insert(ncram,l) - elseif not clear and l and l.cram then - damage_mob(l,"cramming",cramming_damage) + if l then + if clear then + l.cram = nil + elseif l.cram == nil and not self.child then + table.insert(ncram,l) + elseif l.cram then + damage_mob(l,"cramming",cramming_damage) + end end end - for i,l in ipairs(ncram) do + for i,l in pairs(ncram) do if i > entity_cramming_max then l.cram = true else