Fixed a possible bug causing TSPlayer.StrikeNPC to cause NullReferenceExceptions depending on the calling thread.
This commit is contained in:
parent
56d17224b6
commit
f4aa36b8d1
1 changed files with 4 additions and 0 deletions
|
|
@ -899,6 +899,10 @@ namespace TShockAPI
|
|||
|
||||
public void StrikeNPC(int npcid, int damage, float knockBack, int hitDirection)
|
||||
{
|
||||
// Main.rand is thread static.
|
||||
if (Main.rand == null)
|
||||
Main.rand = new Random();
|
||||
|
||||
Main.npc[npcid].StrikeNPC(damage, knockBack, hitDirection);
|
||||
NetMessage.SendData((int) PacketTypes.NpcStrike, -1, -1, "", npcid, damage, knockBack, hitDirection);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue