From 7db908195f06d51fff895a25e48dce74fae5626b Mon Sep 17 00:00:00 2001 From: Cai <13110818005@qq.com> Date: Sun, 11 May 2025 12:00:42 +0800 Subject: [PATCH] fix(OnTileEdit): item disappeared when hitting an ItemFrame without permission --- TShockAPI/Bouncer.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 89ccf7bc..a44365cb 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -29,6 +29,7 @@ using Terraria.DataStructures; using Terraria.Localization; using TShockAPI.Models.PlayerUpdate; using System.Threading.Tasks; +using Terraria.GameContent.Tile_Entities; namespace TShockAPI { @@ -605,6 +606,7 @@ namespace TShockAPI int tileY = args.Y; short editData = args.EditData; EditType type = args.editDetail; + ITile tile = Main.tile[tileX, tileY]; // 'placeStyle' is a term used in Terraria land to determine which frame of a sprite is displayed when the sprite is placed. The placeStyle // determines the frameX and frameY offsets @@ -625,6 +627,15 @@ namespace TShockAPI { TShock.Log.ConsoleDebug(GetString("Bouncer / OnTileEdit rejected from build from {0} {1} {2}", args.Player.Name, action, editData)); + if (tile.type == TileID.ItemFrame) + { + int itemFrameId = TEItemFrame.Find(tileX - tile.frameX % 36 / 18, tileY - tile.frameY % 36 / 18); + if (itemFrameId != -1) + { + NetMessage.SendData((int)PacketTypes.UpdateTileEntity, -1, -1, NetworkText.Empty, itemFrameId, 0, 1); + } + } + GetRollbackRectSize(tileX, tileY, out byte width, out byte length, out int offsetY); args.Player.SendTileRect((short)(tileX - width), (short)(tileY + offsetY), (byte)(width * 2), (byte)(length + 1)); args.Handled = true; @@ -658,7 +669,6 @@ namespace TShockAPI Item selectedItem = args.Player.SelectedItem; int lastKilledProj = args.Player.LastKilledProjectile; - ITile tile = Main.tile[tileX, tileY]; if (action == EditAction.PlaceTile || action == EditAction.ReplaceTile) {