mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 05:43:43 +01:00
Add fake player detection. Tested against pipeworks with eating. Fixes #3976
This commit is contained in:
parent
d264ba70d8
commit
b5025330b9
@ -1,10 +1,23 @@
|
||||
--local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local function is_fake_player(player)
|
||||
-- Simple checks
|
||||
if not player then return true end
|
||||
if player:is_player() == false then return true end
|
||||
if not player.get_player_name then return true end
|
||||
|
||||
-- Check if the player is logged in
|
||||
local objref = minetest.get_player_by_name( player:get_player_name() )
|
||||
if not objref then return true end
|
||||
if objref ~= player then return true end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
-- wrapper for minetest.item_eat (this way we make sure other mods can't break this one)
|
||||
function minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
|
||||
if not user or user:is_player() == false then
|
||||
return itemstack
|
||||
end
|
||||
-- Fake players can't eat food
|
||||
if is_fake_player(user) then return itemstack end
|
||||
|
||||
-- Call on_rightclick if the pointed node defines it
|
||||
if pointed_thing.type == "node" then
|
||||
|
Loading…
Reference in New Issue
Block a user