#198 Fix a crash, step 9

This commit is contained in:
kay27 2022-02-14 06:06:34 +04:00
parent 89a016c0e6
commit 636be37c85
2 changed files with 17 additions and 11 deletions

View File

@ -21,18 +21,11 @@ local interact_priv = minetest.registered_privileges.interact
interact_priv.give_to_singleplayer = false
interact_priv.give_to_admin = false
local is_player = mcl_playerplus.is_player
local overlay = mcl_enchanting.overlay
local hud = "mcl_shield_hud.png"
local function is_player_for_real(obj)
if not obj then return end
if not obj:is_player() then return end
local name = obj:get_player_name()
if not name then return end
if possible_hackers[name] then return end
return true
end
minetest.register_tool("mcl_shields:shield", {
description = S("Shield"),
_doc_items_longdesc = S("A shield is a tool used for protecting the player against attacks."),
@ -132,7 +125,7 @@ mcl_damage.register_modifier(function(obj, damage, reason)
local type = reason.type
local damager = reason.direct
local blocking, shieldstack = mcl_shields.is_blocking(obj)
if is_player_for_real(obj) and blocking and mcl_shields.types[type] and damager then
if is_player(obj) and blocking and mcl_shields.types[type] and damager then
local entity = damager:get_luaentity()
if entity and (type == "arrow" or type == "generic") then
damager = entity._shooter

View File

@ -17,6 +17,8 @@ local is_sprinting = mcl_sprint.is_sprinting
local exhaust = mcl_hunger.exhaust
local playerphysics = playerphysics
local is_player = mcl_player.is_player
local vector = vector
local math = math
-- Internal player state
@ -25,6 +27,17 @@ local mcl_playerplus_internal = {}
local time = 0
local look_pitch = 0
function mcl_playerplus.is_player(obj)
if not obj then return end
if not obj:is_player() then return end
local name = obj:get_player_name()
if not name then return end
if possible_hackers[name] then return end
return true
end
local is_player = mcl_playerplus.is_player
local function player_collision(player)
local pos = player:get_pos()
@ -35,7 +48,7 @@ local function player_collision(player)
for _,object in pairs(minetest.get_objects_inside_radius(pos, width)) do
if object and (object:is_player()
if object and (is_player(object)
or (object:get_luaentity()._cmi_is_mob == true and object ~= player)) then
local pos2 = object:get_pos()