From 62d35533a0ad538010b9b98fe7846e6b9adb5355 Mon Sep 17 00:00:00 2001 From: Rozen Date: Wed, 5 Oct 2022 21:58:09 +0200 Subject: [PATCH 1/3] Init --- CHANGELOG.md | 1 + TShockAPI/GetDataHandlers.cs | 23 ++++++++++------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd7736bb..4e631053 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change. ## Upcoming changes +* Fixed painting wall/tile being rejected from hand of creation. (@Rozen4334) * Reduced load/save console spam. (@SignatureBeef, @YehnBeep) * Replaced SQLite library with Microsoft.Data.Sqlite for arm64 support. (@SignatureBeef) * Initial support for MonoMod hooks on Raspberry Pi (arm64). (@kevzhao2) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index ace40b78..b29a5a91 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -3583,6 +3583,12 @@ namespace TShockAPI return false; } + private static bool HasPaintSprayerAbilities(Item item) + => item is not null && item.stack > 0 && ( + item.type == ItemID.PaintSprayer || + item.type == ItemID.ArchitectGizmoPack || + item.type == ItemID.HandOfCreation); + private static bool HandlePaintTile(GetDataHandlerArgs args) { var x = args.Data.ReadInt16(); @@ -3594,15 +3600,6 @@ namespace TShockAPI TShock.Log.ConsoleDebug("GetDataHandlers / HandlePaintTile rejected range check {0}", args.Player.Name); return true; } - if (OnPaintTile(args.Player, args.Data, x, y, t)) - { - return true; - } - - bool hasPaintSprayerAbilities(Item item) => - item != null - && item.stack > 0 - && (item.type == ItemID.PaintSprayer || item.type == ItemID.ArchitectGizmoPack); // Not selecting paintbrush or paint scraper or the spectre versions? Hacking. if (args.Player.SelectedItem.type != ItemID.PaintRoller && @@ -3611,8 +3608,8 @@ namespace TShockAPI args.Player.SelectedItem.type != ItemID.SpectrePaintRoller && args.Player.SelectedItem.type != ItemID.SpectrePaintScraper && args.Player.SelectedItem.type != ItemID.SpectrePaintbrush && - !args.Player.Accessories.Any(hasPaintSprayerAbilities) && - !args.Player.Inventory.Any(hasPaintSprayerAbilities)) + !args.Player.Accessories.Any(HasPaintSprayerAbilities) && + !args.Player.Inventory.Any(HasPaintSprayerAbilities)) { TShock.Log.ConsoleDebug("GetDataHandlers / HandlePaintTile rejected select consistency {0}", args.Player.Name); args.Player.SendData(PacketTypes.PaintTile, "", x, y, Main.tile[x, y].color()); @@ -3658,8 +3655,8 @@ namespace TShockAPI args.Player.SelectedItem.type != ItemID.SpectrePaintRoller && args.Player.SelectedItem.type != ItemID.SpectrePaintScraper && args.Player.SelectedItem.type != ItemID.SpectrePaintbrush && - !args.Player.Accessories.Any(i => i != null && i.stack > 0 && - (i.type == ItemID.PaintSprayer || i.type == ItemID.ArchitectGizmoPack))) + !args.Player.Accessories.Any(HasPaintSprayerAbilities) && + !args.Player.Inventory.Any(HasPaintSprayerAbilities)) { TShock.Log.ConsoleDebug("GetDataHandlers / HandlePaintWall rejected selector consistency {0}", args.Player.Name); args.Player.SendData(PacketTypes.PaintWall, "", x, y, Main.tile[x, y].wallColor()); From d1505127ddaed57560d4b88911f31a8017d53c35 Mon Sep 17 00:00:00 2001 From: Rozen Date: Wed, 5 Oct 2022 21:59:49 +0200 Subject: [PATCH 2/3] Revert accidental removal of OnPaintTile check --- TShockAPI/GetDataHandlers.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index b29a5a91..cd965d6a 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -3600,6 +3600,10 @@ namespace TShockAPI TShock.Log.ConsoleDebug("GetDataHandlers / HandlePaintTile rejected range check {0}", args.Player.Name); return true; } + if (OnPaintTile(args.Player, args.Data, x, y, t)) + { + return true; + } // Not selecting paintbrush or paint scraper or the spectre versions? Hacking. if (args.Player.SelectedItem.type != ItemID.PaintRoller && From 9b818618f338b073e8ab0cdf6ece0a6d9d8226b1 Mon Sep 17 00:00:00 2001 From: Rozen Date: Thu, 6 Oct 2022 12:06:55 +0200 Subject: [PATCH 3/3] Flip changelog entry to bottom of the list(?) --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e631053..32592e19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,6 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change. ## Upcoming changes -* Fixed painting wall/tile being rejected from hand of creation. (@Rozen4334) * Reduced load/save console spam. (@SignatureBeef, @YehnBeep) * Replaced SQLite library with Microsoft.Data.Sqlite for arm64 support. (@SignatureBeef) * Initial support for MonoMod hooks on Raspberry Pi (arm64). (@kevzhao2) @@ -23,6 +22,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Added preliminary support for Terraria 1.4.4.4. (@SignatureBeef) * GrassSpreadEventArgs Color property has been changed from a Byte to a TileColorCache type. (@SignatureBeef) * SetDefaultsEventArgs now includes a nullable ItemVariant instance. (@SignatureBeef) +* Fixed painting wall/tile being rejected from hand of creation. (@Rozen4334) ## TShock 4.5.18 * Fixed `TSPlayer.GiveItem` not working if the player is in lava. (@gohjoseph)