mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-25 03:51:05 +01:00
25 lines
488 B
Lua
25 lines
488 B
Lua
|
MCLDamageSource = class()
|
||
|
|
||
|
function MCLDamageSource:constructor(tbl, hitter)
|
||
|
for k, v in pairs(tbl or {}) do
|
||
|
self[k] = v
|
||
|
end
|
||
|
self.hitter = hitter
|
||
|
end
|
||
|
|
||
|
MCLDamageSource:__getter("direct_object", function(self)
|
||
|
local hitter = self.hitter
|
||
|
if not hitter then
|
||
|
return
|
||
|
end
|
||
|
return mcl_object_mgr.get(hitter)
|
||
|
end)
|
||
|
|
||
|
MCLDamageSource:__getter("source_object", function(self)
|
||
|
local direct = self:direct_object()
|
||
|
if not direct then
|
||
|
return
|
||
|
end
|
||
|
return direct.source_object or direct
|
||
|
end)
|