Move mcl_util.get_wielded_item to mcl_deathmessages

This commit is contained in:
cora 2024-03-20 20:22:19 +01:00 committed by ryvnf
parent 78692181c0
commit 127de8e4d6
2 changed files with 10 additions and 10 deletions

View File

@ -641,15 +641,6 @@ function mcl_util.get_inventory(object, create)
end
end
function mcl_util.get_wielded_item(object)
if object:is_player() then
return object:get_wielded_item()
else
-- ToDo: implement getting wielditems from mobs as soon as mobs have wielditems
return ItemStack()
end
end
function mcl_util.get_object_name(object)
if object:is_player() then
return object:get_player_name()

View File

@ -131,9 +131,18 @@ mcl_death_messages = {
},
}
local function get_wielded_item(object)
if object:is_player() then
return object:get_wielded_item()
else
-- ToDo: implement getting wielditems from mobs as soon as mobs have wielditems
return ItemStack()
end
end
local function get_item_killer_message(obj, messages, reason)
if messages.item then
local wielded = mcl_util.get_wielded_item(reason.source)
local wielded = get_wielded_item(reason.source)
local itemname = wielded:get_meta():get_string("name")
if itemname ~= "" then
itemname = "[" .. itemname .. "]"