Refuse take/put in wifi chest if there is no more_chest:wifi node near

There was an exploit that can be used in the CSMs to access wifi chest in the any location at any time
This commit is contained in:
Zemtzov7
2023-10-02 22:31:44 +05:00
committed by GitHub
parent 6be81453ca
commit 5b75bde897

View File

@ -87,3 +87,17 @@ minetest.register_on_joinplayer(function(player)
local inv = player:get_inventory()
inv:set_size("more_chests:wifi", 8*4)
end)
minetest.register_allow_player_inventory_action(function(player, action, inventory, inventory_info)
if inventory_info.to_list == "more_chests:wifi" or inventory_info.from_list == "more_chests:wifi" then
local pos = player:get_pos()
local witem = player:get_wielded_item()
local iname = witem and witem:get_name()
local def = iname and minetest.registered_items[iname]
local range = def and def.range or (minetest.is_creative_enabled(player:get_player_name()) and 10 or 4)
local chest = minetest.find_node_near(pos, range, "more_chests:wifi")
if not chest then
return 0
end
end
end)