Update OnTeleport hook with new changes
This commit is contained in:
parent
16df9bb16c
commit
926f97b49f
2 changed files with 23 additions and 10 deletions
|
|
@ -105,6 +105,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
|
||||||
* Modifying ToggleExpert command. Main.expertMode is no longer settable. Using a Main.GameMode int property comparsion.
|
* Modifying ToggleExpert command. Main.expertMode is no longer settable. Using a Main.GameMode int property comparsion.
|
||||||
* GameCulture no longer has static fields to get local language. Using methods to return/compare language.
|
* GameCulture no longer has static fields to get local language. Using methods to return/compare language.
|
||||||
* Added permission "tshock.npc.spawnpets" which restricts pet spawns. This can cause high network load, so it's restricted. (@hakusaro)
|
* Added permission "tshock.npc.spawnpets" which restricts pet spawns. This can cause high network load, so it's restricted. (@hakusaro)
|
||||||
|
* Updated OnTeleport to support new args per protocol changes. (@hakusaro)
|
||||||
|
|
||||||
## TShock 4.3.26
|
## TShock 4.3.26
|
||||||
* Removed the stat tracking system. (@hakusaro)
|
* Removed the stat tracking system. (@hakusaro)
|
||||||
|
|
|
||||||
|
|
@ -1430,8 +1430,8 @@ namespace TShockAPI
|
||||||
/// Flag is a bit field
|
/// Flag is a bit field
|
||||||
/// if the first bit is set -> 0 = player, 1 = NPC
|
/// if the first bit is set -> 0 = player, 1 = NPC
|
||||||
/// if the second bit is set, ignore this packet
|
/// if the second bit is set, ignore this packet
|
||||||
/// if the third bit is set, style +1
|
/// if the third bit is set, "get extra info from target" is true
|
||||||
/// if the fourth bit is set, style +1
|
/// if the fourth bit is set, extra information is valid to read
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public byte Flag { get; set; }
|
public byte Flag { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1442,12 +1442,20 @@ namespace TShockAPI
|
||||||
/// Y Location
|
/// Y Location
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Y { get; set; }
|
public float Y { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Style
|
||||||
|
/// </summary>
|
||||||
|
public byte Style { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// "Extra info"
|
||||||
|
/// </summary>
|
||||||
|
public int ExtraInfo { get; set; }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// NPCStrike - Called when an NPC is attacked
|
/// NPCStrike - Called when an NPC is attacked
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static HandlerList<TeleportEventArgs> Teleport = new HandlerList<TeleportEventArgs>();
|
public static HandlerList<TeleportEventArgs> Teleport = new HandlerList<TeleportEventArgs>();
|
||||||
private static bool OnTeleport(TSPlayer player, MemoryStream data, Int16 id, byte f, float x, float y)
|
private static bool OnTeleport(TSPlayer player, MemoryStream data, Int16 id, byte f, float x, float y, byte style, int extraInfo)
|
||||||
{
|
{
|
||||||
if (Teleport == null)
|
if (Teleport == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1459,7 +1467,9 @@ namespace TShockAPI
|
||||||
ID = id,
|
ID = id,
|
||||||
Flag = f,
|
Flag = f,
|
||||||
X = x,
|
X = x,
|
||||||
Y = y
|
Y = y,
|
||||||
|
Style = style,
|
||||||
|
ExtraInfo = extraInfo
|
||||||
};
|
};
|
||||||
Teleport.Invoke(null, args);
|
Teleport.Invoke(null, args);
|
||||||
return args.Handled;
|
return args.Handled;
|
||||||
|
|
@ -2989,13 +2999,12 @@ namespace TShockAPI
|
||||||
short id = args.Data.ReadInt16();
|
short id = args.Data.ReadInt16();
|
||||||
var x = args.Data.ReadSingle();
|
var x = args.Data.ReadSingle();
|
||||||
var y = args.Data.ReadSingle();
|
var y = args.Data.ReadSingle();
|
||||||
|
byte style = args.Data.ReadInt8();
|
||||||
if (OnTeleport(args.Player, args.Data, id, flag, x, y))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
int type = 0;
|
int type = 0;
|
||||||
byte style = 0;
|
|
||||||
bool isNPC = type == 1;
|
bool isNPC = type == 1;
|
||||||
|
int extraInfo = -1;
|
||||||
|
bool getPositionFromTarget = false;
|
||||||
|
|
||||||
if (flag[0])
|
if (flag[0])
|
||||||
{
|
{
|
||||||
|
|
@ -3007,13 +3016,16 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
if (flag[2])
|
if (flag[2])
|
||||||
{
|
{
|
||||||
style++;
|
getPositionFromTarget = true;
|
||||||
}
|
}
|
||||||
if (flag[3])
|
if (flag[3])
|
||||||
{
|
{
|
||||||
style += 2;
|
extraInfo = args.Data.ReadInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (OnTeleport(args.Player, args.Data, id, flag, x, y, style, extraInfo))
|
||||||
|
return true;
|
||||||
|
|
||||||
//Rod of Discord teleport (usually (may be used by modded clients to teleport))
|
//Rod of Discord teleport (usually (may be used by modded clients to teleport))
|
||||||
if (type == 0 && !args.Player.HasPermission(Permissions.rod))
|
if (type == 0 && !args.Player.HasPermission(Permissions.rod))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue