Created
March 21, 2017 20:04
-
-
Save Brian1KB/e80ade61bbcc87447ae7da8b4d5630a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private object _killSync = new object(); | |
public virtual void Kill() | |
{ | |
lock (_killSync) | |
{ | |
if (IsDead) return; | |
IsDead = true; | |
} | |
Health = 0; | |
Action despawn = delegate | |
{ | |
Entity.DespawnEntity(); | |
}; | |
var player = Entity as Player; | |
if (player != null) | |
{ | |
player.SendUpdateAttributes(); | |
player.BroadcastEntityEvent(); | |
Task.Delay(2000).ContinueWith(task => | |
{ | |
despawn(); | |
player.DropInventory(); | |
var mcpeRespawn = McpeRespawn.CreateObject(); | |
mcpeRespawn.x = player.SpawnPosition.X; | |
mcpeRespawn.y = player.SpawnPosition.Y; | |
mcpeRespawn.z = player.SpawnPosition.Z; | |
player.SendPackage(mcpeRespawn); | |
}).Start(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment