New entity status packet event (#1506)

This commit is contained in:
ReinforceZwei 2021-03-21 22:17:19 +08:00 committed by GitHub
parent 49603db657
commit c15b071cad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 0 deletions

View file

@ -335,6 +335,12 @@ namespace MinecraftClient
/// <param name="protocolversion">Ptotocol version</param>
public virtual void OnEntityMetadata(Entity entity, Dictionary<int, object> metadata) { }
/// <summary>
/// Called when the status of client player have been changed
/// </summary>
/// <param name="statusId"></param>
public virtual void OnPlayerStatus(byte statusId) { }
/// <summary>
/// Called when a network packet received or sent
/// </summary>

View file

@ -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<ChatBot> GetLoadedChatBots()
@ -2076,6 +2077,19 @@ namespace MinecraftClient
}
}
/// <summary>
/// Called when the status of an entity have been changed
/// </summary>
/// <param name="entityID">Entity ID</param>
/// <param name="status">Status ID</param>
public void OnEntityStatus(int entityID, byte status)
{
if (entityID == playerEntityID)
{
DispatchBotEvent(bot => bot.OnPlayerStatus(status));
}
}
/// <summary>
/// Called when server sent a Time Update packet.
/// </summary>

View file

@ -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);

View file

@ -209,6 +209,13 @@ namespace MinecraftClient.Protocol
/// <param name="prop">Dictionary of properties</param>
void OnEntityProperties(int entityID, Dictionary<string, Double> prop);
/// <summary>
/// Called when the status of an entity have been changed
/// </summary>
/// <param name="entityID">Entity ID</param>
/// <param name="status">Status ID</param>
void OnEntityStatus(int entityID, byte status);
/// <summary>
/// Called when the world age has been updated
/// </summary>