Rework self.timer and _owner collision conditions

This commit is contained in:
teknomunk 2024-12-01 09:36:46 -06:00
parent 01c69855b0
commit 1eabc0bb24
4 changed files with 5 additions and 12 deletions

View File

@ -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)

View File

@ -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()

View File

@ -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()

View File

@ -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()