From 7c1cb6dc468a62a2e5ee342b5936d1e95e395dc4 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Sun, 1 Dec 2024 09:36:46 -0600 Subject: [PATCH] Rework self.timer and _owner collision conditions --- mods/ENTITIES/mcl_mobs/init.lua | 5 ++--- mods/ITEMS/mcl_throwing/egg.lua | 4 +--- mods/ITEMS/mcl_throwing/ender_pearl.lua | 4 +--- mods/ITEMS/mcl_throwing/snowball.lua | 4 +--- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/init.lua b/mods/ENTITIES/mcl_mobs/init.lua index f49f0fcb8..10141880c 100644 --- a/mods/ENTITIES/mcl_mobs/init.lua +++ b/mods/ENTITIES/mcl_mobs/init.lua @@ -415,8 +415,7 @@ function mcl_mobs.register_arrow(name, def) damages_players = true, allow_punching = function(self, entity_def, projectile_def, object) if def.allow_punching and not def.allow_punching(self, entity_def, projectile_def, object) then return false end - if self.timer > 2 then return true end - if self._owner and mcl_util.get_entity_id(object) == self._owner then return false end + if self.timer < 2 and self._owner and mcl_util.get_entity_id(object) == self._owner then return false end return true end, @@ -442,7 +441,7 @@ function mcl_mobs.register_arrow(name, def) local entity = object:get_luaentity() if not entity or entity.name == self.object:get_luaentity().name then return end - if self.timer <= 2 then return end + if self.timer < 2 and self._owner and mcl_util.get_entity_id(object) == self._owner then return end if self.hit_mob and entity.is_mob == true then self.hit_mob(self, object) diff --git a/mods/ITEMS/mcl_throwing/egg.lua b/mods/ITEMS/mcl_throwing/egg.lua index aaadab4d6..af6200b13 100644 --- a/mods/ITEMS/mcl_throwing/egg.lua +++ b/mods/ITEMS/mcl_throwing/egg.lua @@ -51,9 +51,7 @@ vl_projectile.register("mcl_throwing:egg_entity",{ vl_projectile.collides_with_entities, }, allow_punching = function(self, _, _, object) - if self._owner == mcl_util.get_entity_id(object) then - return self.timer > 1 - end + if self.timer < 1 and self._owner == mcl_util.get_entity_id(object) then return false end local le = object:get_luaentity() return le and (le.is_mob or le._hittable_by_projectile) or object:is_player() diff --git a/mods/ITEMS/mcl_throwing/ender_pearl.lua b/mods/ITEMS/mcl_throwing/ender_pearl.lua index fd3784ab0..73c0cd237 100644 --- a/mods/ITEMS/mcl_throwing/ender_pearl.lua +++ b/mods/ITEMS/mcl_throwing/ender_pearl.lua @@ -125,9 +125,7 @@ vl_projectile.register("mcl_throwing:ender_pearl_entity",{ "group:plant", "group:mushroom", }, allow_punching = function(self, _, _, object) - if self._owner == mcl_util.get_entity_id(object) then - return self.timer > 1 - end + if self.timer < 1 and self._owner == mcl_util.get_entity_id(object) then return false end local le = object:get_luaentity() return le and (le.is_mob or le._hittable_by_projectile) or object:is_player() diff --git a/mods/ITEMS/mcl_throwing/snowball.lua b/mods/ITEMS/mcl_throwing/snowball.lua index abb474aad..fbfe7931b 100644 --- a/mods/ITEMS/mcl_throwing/snowball.lua +++ b/mods/ITEMS/mcl_throwing/snowball.lua @@ -55,9 +55,7 @@ vl_projectile.register("mcl_throwing:snowball_entity", { vl_projectile.collides_with_entities, }, allow_punching = function(self, _, _, object) - if self._owner == mcl_util.get_entity_id(object) then - return self.timer > 1 - end + if self.timer < 1 and self._owner == mcl_util.get_entity_id(object) then return false end local le = object:get_luaentity() return le and (le.is_mob or le._hittable_by_projectile) or object:is_player()