mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Add auto repsawn if player was dead
This commit is contained in:
parent
ddcc9ee8e6
commit
e93f03bd4e
6 changed files with 37 additions and 0 deletions
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue