Rework self.timer and _owner collision conditions

This commit is contained in:
teknomunk 2024-12-01 09:36:46 -06:00
parent 3897d4b61f
commit 7c1cb6dc46
4 changed files with 5 additions and 12 deletions

@ -415,8 +415,7 @@ function mcl_mobs.register_arrow(name, def)
damages_players = true, damages_players = true,
allow_punching = function(self, entity_def, projectile_def, object) 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 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.timer < 2 and self._owner and mcl_util.get_entity_id(object) == self._owner then return false end
if self._owner and mcl_util.get_entity_id(object) == self._owner then return false end
return true return true
end, end,
@ -442,7 +441,7 @@ function mcl_mobs.register_arrow(name, def)
local entity = object:get_luaentity() local entity = object:get_luaentity()
if not entity or entity.name == self.object:get_luaentity().name then return end 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 if self.hit_mob and entity.is_mob == true then
self.hit_mob(self, object) self.hit_mob(self, object)

@ -51,9 +51,7 @@ vl_projectile.register("mcl_throwing:egg_entity",{
vl_projectile.collides_with_entities, vl_projectile.collides_with_entities,
}, },
allow_punching = function(self, _, _, object) allow_punching = function(self, _, _, object)
if self._owner == mcl_util.get_entity_id(object) then if self.timer < 1 and self._owner == mcl_util.get_entity_id(object) then return false end
return self.timer > 1
end
local le = object:get_luaentity() local le = object:get_luaentity()
return le and (le.is_mob or le._hittable_by_projectile) or object:is_player() return le and (le.is_mob or le._hittable_by_projectile) or object:is_player()

@ -125,9 +125,7 @@ vl_projectile.register("mcl_throwing:ender_pearl_entity",{
"group:plant", "group:mushroom", "group:plant", "group:mushroom",
}, },
allow_punching = function(self, _, _, object) allow_punching = function(self, _, _, object)
if self._owner == mcl_util.get_entity_id(object) then if self.timer < 1 and self._owner == mcl_util.get_entity_id(object) then return false end
return self.timer > 1
end
local le = object:get_luaentity() local le = object:get_luaentity()
return le and (le.is_mob or le._hittable_by_projectile) or object:is_player() return le and (le.is_mob or le._hittable_by_projectile) or object:is_player()

@ -55,9 +55,7 @@ vl_projectile.register("mcl_throwing:snowball_entity", {
vl_projectile.collides_with_entities, vl_projectile.collides_with_entities,
}, },
allow_punching = function(self, _, _, object) allow_punching = function(self, _, _, object)
if self._owner == mcl_util.get_entity_id(object) then if self.timer < 1 and self._owner == mcl_util.get_entity_id(object) then return false end
return self.timer > 1
end
local le = object:get_luaentity() local le = object:get_luaentity()
return le and (le.is_mob or le._hittable_by_projectile) or object:is_player() return le and (le.is_mob or le._hittable_by_projectile) or object:is_player()