diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index f018d093..6fa460a2 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -335,6 +335,12 @@ namespace MinecraftClient /// Ptotocol version public virtual void OnEntityMetadata(Entity entity, Dictionary metadata) { } + /// + /// Called when the status of client player have been changed + /// + /// + public virtual void OnPlayerStatus(byte statusId) { } + /// /// Called when a network packet received or sent /// diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index ad44795d..49d3c143 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -113,6 +113,7 @@ namespace MinecraftClient public bool GetNetworkPacketCaptureEnabled() { return networkPacketCaptureEnabled; } public int GetProtocolVersion() { return protocolversion; } public ILogger GetLogger() { return this.Log; } + public int GetPlayerEntityID() { return playerEntityID; } // get bots list for unloading them by commands public List GetLoadedChatBots() @@ -2076,6 +2077,19 @@ namespace MinecraftClient } } + /// + /// Called when the status of an entity have been changed + /// + /// Entity ID + /// Status ID + public void OnEntityStatus(int entityID, byte status) + { + if (entityID == playerEntityID) + { + DispatchBotEvent(bot => bot.OnPlayerStatus(status)); + } + } + /// /// Called when server sent a Time Update packet. /// diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 4af6da08..cb6081bb 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -1006,6 +1006,14 @@ namespace MinecraftClient.Protocol.Handlers handler.OnEntityMetadata(EntityID, metadata); } break; + case PacketTypesIn.EntityStatus: + if (handler.GetEntityHandlingEnabled()) + { + int entityId = dataTypes.ReadNextInt(packetData); + byte status = dataTypes.ReadNextByte(packetData); + handler.OnEntityStatus(entityId, status); + } + break; case PacketTypesIn.TimeUpdate: long WorldAge = dataTypes.ReadNextLong(packetData); long TimeOfday = dataTypes.ReadNextLong(packetData); diff --git a/MinecraftClient/Protocol/IMinecraftComHandler.cs b/MinecraftClient/Protocol/IMinecraftComHandler.cs index eb8b208e..294023a7 100644 --- a/MinecraftClient/Protocol/IMinecraftComHandler.cs +++ b/MinecraftClient/Protocol/IMinecraftComHandler.cs @@ -209,6 +209,13 @@ namespace MinecraftClient.Protocol /// Dictionary of properties void OnEntityProperties(int entityID, Dictionary prop); + /// + /// Called when the status of an entity have been changed + /// + /// Entity ID + /// Status ID + void OnEntityStatus(int entityID, byte status); + /// /// Called when the world age has been updated ///