From f2e52d97de429420943373a2202df93e8d545e32 Mon Sep 17 00:00:00 2001 From: James Puleo Date: Mon, 10 Oct 2022 09:16:16 -0400 Subject: [PATCH] Allow the Axe of Regrowth and the Rubblemaker to pass Bouncer checks The Axe of Regrowth will place a `Saplings` tile object where a tree used to be, whilst it's `createItem` does not match that of a sapling. Added an exception to allow this interaction to succeed. The Rubblemaker is allowed to place echo piles, which will not match the `createTile` or `placeStyle` of the created piles (except in one very specific case, I suppose). Added an exception to allow this interaction to succeed. The check for the `style` of the placement to match that of `SelectedItem` was moved to be later on, after checking the tile type, and only if the two exceptions above weren't triggered. It will also now sync the tiles upon failure. --- TShockAPI/Bouncer.cs | 56 ++++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 3b384a4b..a0e25628 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -1932,13 +1932,6 @@ namespace TShockAPI return; } - if (args.Player.SelectedItem.placeStyle != style) - { - TShock.Log.ConsoleError(string.Format("Bouncer / OnPlaceObject rejected object placement with invalid style from {0}", args.Player.Name)); - args.Handled = true; - return; - } - //style 52 and 53 are used by ItemID.Fake_newchest1 and ItemID.Fake_newchest2 //These two items cause localised lag and rendering issues if (type == TileID.FakeContainers && (style == 52 || style == 53)) @@ -1975,15 +1968,48 @@ namespace TShockAPI return; } - // This is necessary to check in order to prevent special tiles such as - // queen bee larva, paintings etc that use this packet from being placed - // without selecting the right item. - if (type != args.Player.TPlayer.inventory[args.Player.TPlayer.selectedItem].createTile) + if (args.Player.SelectedItem.type is ItemID.RubblemakerSmall or ItemID.RubblemakerMedium or ItemID.RubblemakerLarge) { - TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected awkward tile creation/selection from {0}", args.Player.Name); - args.Player.SendTileSquareCentered(x, y, 4); - args.Handled = true; - return; + if (type != TileID.LargePilesEcho && type != TileID.LargePiles2Echo && type != TileID.SmallPiles2x1Echo && + type != TileID.SmallPiles1x1Echo && type != TileID.PlantDetritus3x2Echo && type != TileID.PlantDetritus2x2Echo) + { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected rubblemaker I can't believe it's not rubble! from {0}", + args.Player.Name); + args.Player.SendTileSquareCentered(x, y, 4); + args.Handled = true; + return; + } + } + else if(args.Player.SelectedItem.type == ItemID.AcornAxe) + { + if (type != TileID.Saplings) + { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected Axe of Regrowth only places saplings {0}", args.Player.Name); + args.Player.SendTileSquareCentered(x, y, 4); + args.Handled = true; + return; + } + } + else + { + // This is necessary to check in order to prevent special tiles such as + // queen bee larva, paintings etc that use this packet from being placed + // without selecting the right item. + if (type != args.Player.TPlayer.inventory[args.Player.TPlayer.selectedItem].createTile) + { + TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected awkward tile creation/selection from {0}", args.Player.Name); + args.Player.SendTileSquareCentered(x, y, 4); + args.Handled = true; + return; + } + + if (args.Player.SelectedItem.placeStyle != style) + { + TShock.Log.ConsoleError(string.Format("Bouncer / OnPlaceObject rejected object placement with invalid style from {0}", args.Player.Name)); + args.Player.SendTileSquareCentered(x, y, 4); + args.Handled = true; + return; + } } TileObjectData tileData = TileObjectData.GetTileData(type, style, 0);