diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index fb4119605..2121de57a 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -731,3 +731,13 @@ function mcl_util.get_entity_id(entity) return id end end +function mcl_util.get_entity_from_id(id) + local player = minetest.get_player_by_name(id) + if player then return player end + + for i,le in pairs(minetest.luaentities) do + if le._uuid == id then return le.object end + end + + return nil +end diff --git a/mods/ITEMS/vl_projectile/init.lua b/mods/ITEMS/vl_projectile/init.lua index 3b0d81a1c..169e3d9d9 100644 --- a/mods/ITEMS/vl_projectile/init.lua +++ b/mods/ITEMS/vl_projectile/init.lua @@ -491,7 +491,7 @@ local function handle_entity_collision(self, entity_def, projectile_def, object) dmg = dmg(self, entity_def, projectile_def, object) end - object:punch(self.object, 1.0, projectile_def.tool or { full_punch_interval = 1.0, damage_groups = dmg }, dir ) + mcl_util.deal_damage(object, dmg.fleshy, {type = projectile_def.damage_type or "arrow", source = mcl_util.get_entity_from_id(self._owner), direct = self.object}) -- Guard against crashes when projectiles get destroyed in response to what it punched if not self.object:get_pos() then return true end