From 5b75bde8974c2d844f4043996867c232062559ea Mon Sep 17 00:00:00 2001 From: Zemtzov7 <72821250+zmv7@users.noreply.github.com> Date: Mon, 2 Oct 2023 22:31:44 +0500 Subject: [PATCH] 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 --- models/wifi.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/models/wifi.lua b/models/wifi.lua index 506bac9..40d5e6c 100644 --- a/models/wifi.lua +++ b/models/wifi.lua @@ -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)