forked from MineClone5/MineClone5
#198 Fix a crash, step 12
This commit is contained in:
parent
b86446df34
commit
1537232f17
|
@ -498,3 +498,23 @@ function mcl_util.get_pointed_thing(player)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
local possible_hackers = {}
|
||||
|
||||
function mcl_util.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_on_authplayer(function(name, ip, is_success)
|
||||
if not is_success then return end
|
||||
possible_hackers[name] = true
|
||||
end)
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
possible_hackers[player:get_player_name()] = nil
|
||||
end)
|
||||
|
|
|
@ -42,14 +42,7 @@ item_drop_settings.drop_single_item = false --if true, the drop control dro
|
|||
|
||||
item_drop_settings.magnet_time = 0.75 -- how many seconds an item follows the player before giving up
|
||||
|
||||
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
|
||||
function is_player = mcl_util.is_player
|
||||
|
||||
local function get_gravity()
|
||||
return tonumber(minetest.settings:get("movement_gravity")) or 9.81
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name = mcl_item_entity
|
||||
author = PilzAdam
|
||||
description = Dropped items will be attracted to the player like a magnet.
|
||||
depends = flowlib, mcl_enchanting
|
||||
depends = flowlib, mcl_enchanting, mcl_util
|
||||
|
|
|
@ -2,8 +2,6 @@ local minetest, math, vector = minetest, math, vector
|
|||
local modname = minetest.get_current_modname()
|
||||
local S = minetest.get_translator(modname)
|
||||
|
||||
local possible_hackers = {}
|
||||
|
||||
mcl_shields = {
|
||||
types = {
|
||||
mob = true,
|
||||
|
@ -24,14 +22,7 @@ interact_priv.give_to_admin = false
|
|||
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
|
||||
local is_player = mcl_util.is_player
|
||||
|
||||
minetest.register_tool("mcl_shields:shield", {
|
||||
description = S("Shield"),
|
||||
|
@ -298,7 +289,7 @@ local function update_shield_entity(player, blocking, i)
|
|||
end
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for _, player in pairs(minetest.get_connected_players()) do if not possible_hackers[player:get_player_name()] then
|
||||
for _, player in pairs(minetest.get_connected_players()) do if is_player(player) then
|
||||
handle_blocking(player)
|
||||
|
||||
local blocking, shieldstack = mcl_shields.is_blocking(player)
|
||||
|
@ -472,13 +463,7 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv
|
|||
return craft_banner_on_shield(itemstack, player, old_craft_grid, craft_inv)
|
||||
end)
|
||||
|
||||
minetest.register_on_authplayer(function(name, ip, is_success)
|
||||
if not is_success then return end
|
||||
possible_hackers[name] = true
|
||||
end)
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
possible_hackers[player:get_player_name()] = nil
|
||||
mcl_shields.players[player] = {
|
||||
shields = {},
|
||||
blocking = 0,
|
||||
|
|
|
@ -27,15 +27,6 @@ local mcl_playerplus_internal = {}
|
|||
local time = 0
|
||||
local look_pitch = 0
|
||||
|
||||
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
|
||||
|
||||
local function player_collision(player)
|
||||
|
||||
local pos = player:get_pos()
|
||||
|
|
Loading…
Reference in New Issue