From 7e9388b80d8c050ff807c1fe64c0541949a57937 Mon Sep 17 00:00:00 2001 From: kay27 Date: Mon, 14 Feb 2022 06:15:03 +0400 Subject: [PATCH] #198 Fix a crash, step 10 --- mods/ENTITIES/mcl_item_entity/init.lua | 5 ++--- mods/ITEMS/mcl_shields/init.lua | 11 +++++++++-- mods/PLAYER/mcl_player/mod.conf | 1 + mods/PLAYER/mcl_playerplus/init.lua | 4 +--- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 91e152ca1..f9a717455 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -6,9 +6,8 @@ local pool = {} local tick = false -minetest.register_on_joinplayer(function(player) - local name - name = player:get_player_name() +minetest.register_on_authplayer(function(name, ip, is_success) + if not is_success then return end pool[name] = 0 end) diff --git a/mods/ITEMS/mcl_shields/init.lua b/mods/ITEMS/mcl_shields/init.lua index cfcd721fb..671c42c76 100644 --- a/mods/ITEMS/mcl_shields/init.lua +++ b/mods/ITEMS/mcl_shields/init.lua @@ -21,11 +21,18 @@ 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" +function 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 + 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."), diff --git a/mods/PLAYER/mcl_player/mod.conf b/mods/PLAYER/mcl_player/mod.conf index 97ccce8e6..d092bd3f3 100644 --- a/mods/PLAYER/mcl_player/mod.conf +++ b/mods/PLAYER/mcl_player/mod.conf @@ -1,3 +1,4 @@ name = mcl_player author = celeron55 description = Adds the 3D player model, taken from Minetest Game 0.4.16. +depends = mcl_shields diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 1616e3e68..6a191a05a 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -27,7 +27,7 @@ local mcl_playerplus_internal = {} local time = 0 local look_pitch = 0 -function mcl_playerplus.is_player(obj) +function is_player(obj) if not obj then return end if not obj:is_player() then return end local name = obj:get_player_name() @@ -36,8 +36,6 @@ function mcl_playerplus.is_player(obj) return true end -local is_player = mcl_playerplus.is_player - local function player_collision(player) local pos = player:get_pos()