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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
TimeUpdate,
|
||||
EntityTeleport,
|
||||
EntityStatus,
|
||||
UpdateHealth,
|
||||
UnknownPacket
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -725,6 +725,13 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
handler.OnEntityTeleport(EntityID, X, Y, Z, OnGround);
|
||||
}
|
||||
break;
|
||||
case PacketIncomingType.UpdateHealth:
|
||||
float health = dataTypes.ReadNextFloat(packetData);
|
||||
// don't need them
|
||||
dataTypes.ReadNextVarInt(packetData);
|
||||
dataTypes.ReadNextFloat(packetData);
|
||||
handler.OnUpdateHealth(health);
|
||||
break;
|
||||
default:
|
||||
return false; //Ignored packet
|
||||
}
|
||||
|
|
|
|||
|
|
@ -277,6 +277,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
case 0x59: return PacketIncomingType.EntityProperties;
|
||||
case 0x57: return PacketIncomingType.EntityTeleport;
|
||||
case 0x1C: return PacketIncomingType.EntityStatus;
|
||||
case 0x49: return PacketIncomingType.UpdateHealth; // TODO: Add backwards support for this packet
|
||||
default: return PacketIncomingType.UnknownPacket;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,6 +212,8 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="item">Item (may be null for empty slot)</param>
|
||||
void OnSetSlot(byte inventoryID, short slotID, Item item);
|
||||
|
||||
void OnUpdateHealth(float health);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the Player entity ID has been received from the server
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ namespace MinecraftClient
|
|||
public static bool ResolveSrvRecords = true;
|
||||
public static bool ResolveSrvRecordsShortTimeout = true;
|
||||
public static bool EntityHandling = false;
|
||||
public static bool AutoRespawn = false;
|
||||
|
||||
//AntiAFK Settings
|
||||
public static bool AntiAFK_Enabled = false;
|
||||
|
|
@ -240,6 +241,7 @@ namespace MinecraftClient
|
|||
case "botmessagedelay": botMessageDelay = TimeSpan.FromSeconds(str2int(argValue)); break;
|
||||
case "debugmessages": DebugMessages = str2bool(argValue); break;
|
||||
case "enableentityhandling": EntityHandling = str2bool(argValue); break;
|
||||
case "autorespawn": AutoRespawn = str2bool(argValue); break;
|
||||
|
||||
case "botowners":
|
||||
Bots_Owners.Clear();
|
||||
|
|
@ -583,6 +585,7 @@ namespace MinecraftClient
|
|||
+ "scriptcache=true # Cache compiled scripts for faster load on low-end devices\r\n"
|
||||
+ "timestamps=false # Prepend timestamps to chat messages\r\n"
|
||||
+ "enableentityhandling=false # Toggle entities handling\r\n"
|
||||
+ "autorespawn=false # Toggle auto respawn if client player was dead (make sure your spawn point is safe)\r\n"
|
||||
+ "\r\n"
|
||||
+ "[AppVars]\r\n"
|
||||
+ "# yourvar=yourvalue\r\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue