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.
This commit is contained in:
James Puleo 2022-10-10 09:16:16 -04:00
parent b3a6495eba
commit f2e52d97de
No known key found for this signature in database
GPG key ID: 3E16C7EFA34FB15D

View file

@ -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,6 +1968,30 @@ namespace TShockAPI
return;
}
if (args.Player.SelectedItem.type is ItemID.RubblemakerSmall or ItemID.RubblemakerMedium or ItemID.RubblemakerLarge)
{
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.
@ -1986,6 +2003,15 @@ 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.Player.SendTileSquareCentered(x, y, 4);
args.Handled = true;
return;
}
}
TileObjectData tileData = TileObjectData.GetTileData(type, style, 0);
if (tileData == null)
{