From 401e18760adc308d56159a1bc8d8389541f61138 Mon Sep 17 00:00:00 2001 From: marco_a <4279489-marco_a@users.noreply.gitlab.com> Date: Wed, 24 Apr 2024 22:59:23 +0200 Subject: [PATCH] Bugfix: spectate hand wasn't overwritten if there was already another hand put by another mod --- src/spectate/spectate_main.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/spectate/spectate_main.lua b/src/spectate/spectate_main.lua index 735657e..a774f19 100644 --- a/src/spectate/spectate_main.lua +++ b/src/spectate/spectate_main.lua @@ -4,7 +4,7 @@ local function override_hotbar() end local function set_spectator() end local players_in_spectate_mode = {} -- KEY: player name, VALUE: {(string) minigame, (int) arenaID, (string) type, (string) spectating} -local spectate_temp_storage = {} -- KEY: player_name, VALUE: {(table) camera_offset, (string) inventory_fs} +local spectate_temp_storage = {} -- KEY: player_name, VALUE: {(table) camera_offset, (string) inventory_fs, (ItemStack) hand} local players_spectated = {} -- KEY: player name, VALUE: {(string) spectator(s) = true} local entities_spectated = {} -- KEY: [mod][arena_name][entity name], VALUE: {(string) spectator(s) = true} local areas_spectated = {} -- KEY: [mod][arena_name][area_name], VALUE: {(string) spectator(s) = true} @@ -95,16 +95,17 @@ function arena_lib.enter_spectate_mode(p_name, arena, xc_name) end end - -- applico mano finta - player:get_inventory():set_size("hand", 1) - player:get_inventory():add_item("hand", "arena_lib:spectate_hand") - -- che siano entrati anche come giocatori o meno, non importa, in quanto operations_before_entering_arena -- viene eseguita prima dell'entrata nella spettatore, e quindi questi parametri -- sono giĆ  stati eventualmente salvati nell'archiviazione di arena_lib spectate_temp_storage[p_name] = {} spectate_temp_storage[p_name].camera_offset = {player:get_eye_offset()} spectate_temp_storage[p_name].inventory_fs = player:get_inventory_formspec() + spectate_temp_storage[p_name].hand = player:get_inventory():get_stack("hand", 1) + + -- applico mano finta + player:get_inventory():set_size("hand", 1) + player:get_inventory():set_stack("hand", 1, "arena_lib:spectate_hand") -- applicazione parametri vari local current_properties = table.copy(player:get_properties()) @@ -172,6 +173,7 @@ function arena_lib.leave_spectate_mode(p_name) -- verranno eventualmente poi sovrascritti da quelli nell'archiviazione di arena_lib player:set_eye_offset(spectate_temp_storage[p_name].camera_offset[1], spectate_temp_storage[p_name].camera_offset[2]) player:set_inventory_formspec(spectate_temp_storage[p_name].inventory_fs) + player:get_inventory():set_stack("hand", 1, spectate_temp_storage[p_name].hand) spectate_temp_storage[p_name] = nil player:set_detach()