Add auto repsawn if player was dead

This commit is contained in:
ReinforceZwei 2020-04-01 18:28:00 +08:00 committed by ORelio
parent ddcc9ee8e6
commit e93f03bd4e
6 changed files with 37 additions and 0 deletions

View file

@ -11,6 +11,7 @@ using MinecraftClient.Proxy;
using MinecraftClient.Protocol.Handlers.Forge;
using MinecraftClient.Mapping;
using MinecraftClient.Inventory;
using System.Threading.Tasks;
namespace MinecraftClient
{
@ -1380,5 +1381,27 @@ namespace MinecraftClient
return false;
}
}
/// <summary>
/// Called when client player's health changed, e.g. getting attack
/// </summary>
/// <param name="health">Player current health</param>
public void OnUpdateHealth(float health)
{
if (Settings.AutoRespawn)
{
if (health <= 0)
{
ConsoleIO.WriteLine("Client player dead.");
ConsoleIO.WriteLine("Respawn after 1 second...");
Task.Factory.StartNew(delegate
{
// wait before respawn
Thread.Sleep(1000);
SendRespawnPacket();
});
}
}
}
}
}