mirror of
https://github.com/minetest-mods/more_chests.git
synced 2025-07-06 17:10:21 +02:00
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:
@ -87,3 +87,17 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
inv:set_size("more_chests:wifi", 8*4)
|
inv:set_size("more_chests:wifi", 8*4)
|
||||||
end)
|
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)
|
||||||
|
Reference in New Issue
Block a user