Merge branch 'general-devel' into playerdata-changes

This commit is contained in:
Lucas Nicodemus 2025-03-10 00:39:33 +09:00 committed by GitHub
commit 13a4a0864b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 2219 additions and 1145 deletions

View file

@ -177,8 +177,13 @@ namespace TShockAPI
/// </summary>
public int RPPending = 0;
public int sX = -1;
public int sY = -1;
public bool initialSpawn = false;
public int initialServerSpawnX = -2;
public int initialServerSpawnY = -2;
public bool spawnSynced = false;
public int initialClientSpawnX = -2;
public int initialClientSpawnY = -2;
/// <summary>
/// A queue of tiles destroyed by the player for reverting.
@ -351,6 +356,9 @@ namespace TShockAPI
/// <summary>Determines if the player is disabled for not clearing their trash. A re-login is the only way to reset this.</summary>
public bool IsDisabledPendingTrashRemoval;
/// <summary>Determines if the player has finished the handshake (Sent all necessary packets for connection, such as Request World Data, Spawn Player, etc). A normal client would do all of this no problem.</summary>
public bool FinishedHandshake = false;
/// <summary>Checks to see if active throttling is happening on events by Bouncer. Rejects repeated events by malicious clients in a short window.</summary>
/// <returns>If the player is currently being throttled by Bouncer, or not.</returns>
public bool IsBouncerThrottled()
@ -1380,6 +1388,25 @@ namespace TShockAPI
return true;
}
/// <summary>
/// Teleports the player to their spawnpoint.
/// Teleports to main spawnpoint if their bed is not active.
/// Supports SSC.
/// </summary>
public bool TeleportSpawnpoint()
{
// NOTE: it is vanilla behaviour to not permanently override the spawnpoint if the bed spawn is broken/invalid
int x = TPlayer.SpawnX;
int y = TPlayer.SpawnY;
if ((x == -1 && y == -1) ||
!Main.tile[x, y - 1].active() || Main.tile[x, y - 1].type != TileID.Beds || !WorldGen.StartRoomCheck(x, y - 1))
{
x = Main.spawnTileX;
y = Main.spawnTileY;
}
return Teleport(x * 16, y * 16 - 48);
}
/// <summary>
/// Heals the player.
/// </summary>
@ -1394,14 +1421,7 @@ namespace TShockAPI
/// </summary>
public void Spawn(PlayerSpawnContext context, int? respawnTimer = null)
{
if (this.sX > 0 && this.sY > 0)
{
Spawn(this.sX, this.sY, context, respawnTimer);
}
else
{
Spawn(TPlayer.SpawnX, TPlayer.SpawnY, context, respawnTimer);
}
Spawn(TPlayer.SpawnX, TPlayer.SpawnY, context, respawnTimer);
}
/// <summary>