diff --git a/CHANGELOG.md b/CHANGELOG.md
index 612bfb4f..c8b9cb83 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large.
+## Upcoming changes
+* Update player spawn related things to 1.4. `Terraria.Player.Spawn` method now has a required argument, `PlayerSpawnContext context`. (@AxeelAnder)
+
## TShock 4.4.0 (Pre-release 4)
* Debug logging now provides ConsoleDebug and ILog has been updated to support the concept of debug logs. Debug logs are now controlled by `config.json` instead of by preprocessor debug flag. (@hakusaro)
* Removed `/confuse` command and Terraria player data resync from @Zidonuke. (@hakusaro)
diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs
index a0a5dee9..0231e9a9 100644
--- a/TShockAPI/Bouncer.cs
+++ b/TShockAPI/Bouncer.cs
@@ -164,7 +164,7 @@ namespace TShockAPI
var lastTileY = args.Player.LastNetPosition.Y - 48;
if (!args.Player.Teleport(lastTileX, lastTileY))
{
- args.Player.Spawn();
+ args.Player.Spawn(PlayerSpawnContext.RecallFromItem);
}
TShock.Log.ConsoleDebug("Bouncer / OnPlayerUpdate rejected from (??) {0}", args.Player.Name);
args.Handled = true;
@@ -491,7 +491,7 @@ namespace TShockAPI
return;
}
}
-
+
/// Bouncer's SendTileSquare hook halts large scope world destruction.
/// The object that triggered the event.
/// The packet arguments that the event has.
@@ -684,7 +684,7 @@ namespace TShockAPI
args.Handled = true;
}
-
+
/// Registered when items fall to the ground to prevent cheating.
/// The object that triggered the event.
/// The packet arguments that the event has.
@@ -969,7 +969,7 @@ namespace TShockAPI
return;
}
}
-
+
/// Handles ProjectileKill events for throttling and out of bounds projectiles.
/// The object that triggered the event.
/// The packet arguments that the event has.
@@ -995,7 +995,7 @@ namespace TShockAPI
return;
}
}
-
+
/// Handles when a chest item is changed.
/// The object that triggered the event.
/// The packet arguments that the event has.
@@ -1032,7 +1032,7 @@ namespace TShockAPI
return;
}
}
-
+
/// The Bouncer handler for when chests are opened.
/// The object that triggered the event.
/// The packet arguments that the event has.
@@ -1059,7 +1059,7 @@ namespace TShockAPI
int id = Chest.FindChest(args.X, args.Y);
args.Player.ActiveChest = id;
}
-
+
/// The place chest event that Bouncer hooks to prevent accidental damage.
/// The object that triggered the event.
/// The packet arguments that the event has.
@@ -1119,7 +1119,7 @@ namespace TShockAPI
return;
}
}
-
+
/// Handles PlayerZone events for preventing spawning NPC maliciously.
/// The object that triggered the event.
/// The packet arguments that the event has.
@@ -1155,7 +1155,7 @@ namespace TShockAPI
}
}
}
-
+
/// Handles basic animation throttling for disabled players.
/// sender
/// args
@@ -1175,7 +1175,7 @@ namespace TShockAPI
return;
}
}
-
+
/// Handles Bouncer's liquid set anti-cheat.
/// The object that triggered the event.
/// The packet arguments that the event has.
@@ -1315,7 +1315,7 @@ namespace TShockAPI
return;
}
}
-
+
/// Handles Buff events.
/// The object that triggered the event.
/// The packet arguments that the event has.
@@ -1372,7 +1372,7 @@ namespace TShockAPI
return;
}
}
-
+
/// Handles NPCAddBuff events.
/// The object that triggered the event.
/// The packet arguments that the event has.
@@ -1432,7 +1432,7 @@ namespace TShockAPI
args.Handled = true;
}
}
-
+
/// The Bouncer handler for when an NPC is rehomed.
/// The object that triggered the event.
/// The packet arguments that the event has.
@@ -1459,7 +1459,7 @@ namespace TShockAPI
return;
}
}
-
+
/// Bouncer's HealOther handler prevents gross misuse of HealOther packets by hackers.
/// The object that triggered the event.
/// The packet arguments that the event has.
@@ -1501,7 +1501,7 @@ namespace TShockAPI
args.Handled = false;
return;
}
-
+
/// Bouncer's PlaceObject hook reverts malicious tile placement.
/// The object that triggered the event.
/// The packet arguments that the event has.
@@ -1571,8 +1571,8 @@ namespace TShockAPI
return;
}
- // This is neccessary to check in order to prevent special tiles such as
- // queen bee larva, paintings etc that use this packet from being placed
+ // This is neccessary 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)
{
@@ -1634,7 +1634,7 @@ namespace TShockAPI
args.Player.TilesCreated.Add(coords, Main.tile[x, y]);
}
}
-
+
/// Fired when a PlaceTileEntity occurs for basic anti-cheat on perms and range.
/// The object that triggered the event.
/// The packet arguments that the event has.
@@ -1658,7 +1658,7 @@ namespace TShockAPI
return;
}
}
-
+
/// Fired when an item frame is placed for anti-cheat detection.
/// The object that triggered the event.
/// The packet arguments that the event has.
@@ -1685,7 +1685,7 @@ namespace TShockAPI
return;
}
}
-
+
internal void OnPlayerPortalTeleport(object sender, GetDataHandlers.TeleportThroughPortalEventArgs args)
{
//Packet 96 (player teleport through portal) has no validation on whether or not the player id provided
@@ -1713,7 +1713,7 @@ namespace TShockAPI
return;
}
}
-
+
/// Handles the anti-cheat components of gem lock toggles.
/// The object that triggered the event.
/// The packet arguments that the event has.
@@ -1743,7 +1743,7 @@ namespace TShockAPI
return;
}
}
-
+
/// Handles validation of of basic anti-cheat on mass wire operations.
/// The object that triggered the event.
/// The packet arguments that the event has.
diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs
index d32e1155..636f269d 100644
--- a/TShockAPI/Commands.cs
+++ b/TShockAPI/Commands.cs
@@ -2565,7 +2565,7 @@ namespace TShockAPI
private static void Home(CommandArgs args)
{
- args.Player.Spawn();
+ args.Player.Spawn(PlayerSpawnContext.RecallFromItem);
args.Player.SendSuccessMessage("Teleported to your spawnpoint.");
}
diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs
index df94e7f1..93d79dea 100644
--- a/TShockAPI/GetDataHandlers.cs
+++ b/TShockAPI/GetDataHandlers.cs
@@ -2092,7 +2092,7 @@ namespace TShockAPI
if (respawnTimer > 0)
args.Player.Dead = true;
- else
+ else
args.Player.Dead = false;
return false;
}
@@ -2662,7 +2662,7 @@ namespace TShockAPI
if (type == 1 && TShock.Config.DisableDungeonGuardian)
{
args.Player.SendMessage("The Dungeon Guardian returned you to your spawn point", Color.Purple);
- args.Player.Spawn();
+ args.Player.Spawn(PlayerSpawnContext.RecallFromItem);
return true;
}
diff --git a/TShockAPI/Net/SpawnMsg.cs b/TShockAPI/Net/SpawnMsg.cs
index 8505f868..8f0d2752 100644
--- a/TShockAPI/Net/SpawnMsg.cs
+++ b/TShockAPI/Net/SpawnMsg.cs
@@ -1,4 +1,4 @@
-/*
+/*
TShock, a server mod for Terraria
Copyright (C) 2011-2019 Pryaxis & TShock Contributors
@@ -18,6 +18,7 @@ along with this program. If not, see .
using System.IO;
using System.IO.Streams;
+using Terraria;
namespace TShockAPI.Net
{
@@ -28,15 +29,19 @@ namespace TShockAPI.Net
get { return PacketTypes.PlayerSpawn; }
}
+ public byte PlayerIndex { get; set; }
public short TileX { get; set; }
public short TileY { get; set; }
- public byte PlayerIndex { get; set; }
+ public int RespawnTimer { get; set; }
+ public PlayerSpawnContext PlayerSpawnContext { get; set; }
public override void Pack(Stream stream)
{
stream.WriteInt8(PlayerIndex);
- stream.WriteInt32(TileX);
- stream.WriteInt32(TileY);
+ stream.WriteInt16(TileX);
+ stream.WriteInt16(TileY);
+ stream.WriteInt32(RespawnTimer);
+ stream.WriteByte((byte) PlayerSpawnContext);
}
}
-}
\ No newline at end of file
+}
diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs
index 9a772227..8f450604 100644
--- a/TShockAPI/TSPlayer.cs
+++ b/TShockAPI/TSPlayer.cs
@@ -297,7 +297,11 @@ namespace TShockAPI
///
/// The player's respawn timer.
///
- public int RespawnTimer;
+ public int RespawnTimer
+ {
+ get => TPlayer.respawnTimer;
+ set => TPlayer.respawnTimer = value;
+ }
///
/// Whether the player is dead or not.
@@ -569,7 +573,7 @@ namespace TShockAPI
}
}
}
-
+
}
return check;
@@ -1164,15 +1168,15 @@ namespace TShockAPI
///
/// Spawns the player at his spawn point.
///
- public void Spawn()
+ public void Spawn(PlayerSpawnContext context, int? respawnTimer = null)
{
if (this.sX > 0 && this.sY > 0)
{
- Spawn(this.sX, this.sY);
+ Spawn(this.sX, this.sY, context, respawnTimer);
}
else
{
- Spawn(TPlayer.SpawnX, TPlayer.SpawnY);
+ Spawn(TPlayer.SpawnX, TPlayer.SpawnY, context, respawnTimer);
}
}
@@ -1181,7 +1185,9 @@ namespace TShockAPI
///
/// The X coordinate.
/// The Y coordinate.
- public void Spawn(int tilex, int tiley)
+ /// The PlayerSpawnContext.
+ /// The respawn timer, will be Player.respawnTimer if parameter is null.
+ public void Spawn(int tilex, int tiley, PlayerSpawnContext context, int? respawnTimer = null)
{
using (var ms = new MemoryStream())
{
@@ -1189,7 +1195,9 @@ namespace TShockAPI
{
PlayerIndex = (byte)Index,
TileX = (short)tilex,
- TileY = (short)tiley
+ TileY = (short)tiley,
+ RespawnTimer = respawnTimer ?? TShock.Players[Index].TPlayer.respawnTimer,
+ PlayerSpawnContext = context,
};
msg.PackFull(ms);
SendRawData(ms.ToArray());
@@ -1215,7 +1223,7 @@ namespace TShockAPI
}
}
- /// Sends a tile square at a location with a given size.
+ /// Sends a tile square at a 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.
@@ -1624,7 +1632,7 @@ namespace TShockAPI
public void SendMultipleMatchError(IEnumerable