Merge remote-tracking branch 'origin/general-devel' into otapi3

This commit is contained in:
Lucas Nicodemus 2022-02-16 18:44:33 -08:00
commit 78169c87cb
11 changed files with 117 additions and 71 deletions

View file

@ -1226,7 +1226,7 @@ namespace TShockAPI
y = 992;
}
SendTileSquare((int)(x / 16), (int)(y / 16), 15);
SendTileSquareCentered((int)(x / 16), (int)(y / 16), 15);
TPlayer.Teleport(new Vector2(x, y), style);
NetMessage.SendData((int)PacketTypes.Teleport, -1, -1, NetworkText.Empty, 0, TPlayer.whoAmI, x, y, style);
return true;
@ -1308,11 +1308,27 @@ namespace TShockAPI
/// <param name="y">The y coordinate to send.</param>
/// <param name="size">The size square set of tiles to send.</param>
/// <returns>true if the tile square was sent successfully, else false</returns>
[Obsolete("This method may not send tiles the way you would expect it to. The (x,y) coordinates are the top left corner of the tile square, switch to " + nameof(SendTileSquareCentered) + " if you wish for the coordindates to be the center of the square.")]
public virtual bool SendTileSquare(int x, int y, int size = 10)
{
return SendTileRect((short)x, (short)y, (byte)size, (byte)size);
}
/// <summary>
/// Sends a tile square at a center location with a given size.
/// Typically used to revert changes by Bouncer through sending the
/// "old" version of modified data back to a client.
/// Prevents desync issues.
/// </summary>
/// <param name="x">The x coordinates of the center of the square.</param>
/// <param name="y">The y coordinates of the center of the square.</param>
/// <param name="size">The size square set of tiles to send.</param>
/// <returns>true if the tile square was sent successfully, else false</returns>
public virtual bool SendTileSquareCentered(int x, int y, byte size = 10)
{
return SendTileRect((short)(x - (size / 2)), (short)(y - (size / 2)), size, size);
}
/// <summary>
/// Sends a rectangle of tiles at a location with the given length and width.
/// </summary>
@ -1347,7 +1363,7 @@ namespace TShockAPI
public bool GiveItemCheck(int type, string name, int stack, int prefix = 0)
{
if ((TShock.ItemBans.DataModel.ItemIsBanned(name) && TShock.Config.Settings.PreventBannedItemSpawn) &&
(TShock.ItemBans.DataModel.ItemIsBanned(name, this) || !TShock.Config.Settings.AllowAllowedGroupsToSpawnBannedItems))
(TShock.ItemBans.DataModel.ItemIsBanned(name, this) || !TShock.Config.Settings.AllowAllowedGroupsToSpawnBannedItems))
return false;
GiveItem(type, stack, prefix);