diff --git a/mobf/debug.lua b/mobf/debug.lua index c842812..a81a492 100644 --- a/mobf/debug.lua +++ b/mobf/debug.lua @@ -428,12 +428,14 @@ function mobf_debug.rightclick_callback(entity,player) print("MOBF: \t\t " .. k .. ": " .. v.value) end - local attention_name = tostring(entity.dynamic_data.attention.most_relevant_target) - - if (entity.dynamic_data.attention.most_relevant_target:is_player()) then - attention_name = entity.dynamic_data.attention.most_relevant_target:get_player_name() + if entity.dynamic_data.attention.most_relevant_target ~= nil then + local attention_name = tostring(entity.dynamic_data.attention.most_relevant_target) + + if (entity.dynamic_data.attention.most_relevant_target:is_player()) then + attention_name = entity.dynamic_data.attention.most_relevant_target:get_player_name() + end + print("MOBF: \tTop attention object: " .. attention_name) end - print("MOBF: \tTop attention object: " .. attention_name) end if entity.dynamic_data.graphics.last_fps ~= nil then diff --git a/mobf/fighting.lua b/mobf/fighting.lua index 196f80a..1b34dce 100644 --- a/mobf/fighting.lua +++ b/mobf/fighting.lua @@ -847,14 +847,13 @@ function fighting.melee_attack_handler(entity,now,distance) return false end + mobf_assert_backtrace( entity.dynamic_data.combat.target ~= nil) local ownpos = entity.object:getpos() - local target_obj = entity.dynamic_data.combat.target.object + local target_obj = entity.dynamic_data.combat.target.object - mobf_assert_backtrace(target ~= nil) - if target:is_player() then + if target_obj == nil then target_obj = entity.dynamic_data.combat.target end - mobf_assert_backtrace(target_obj ~= nil) if distance <= entity.data.combat.melee.range and mobf_line_of_sight(ownpos,target_obj:getpos()) then