mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Add Entity.Item, Entity.CustomName, OnEntityMetadata event (#1222)
* Add New Event * new Event * Add OnEntityMetadaTa * Update ChatBot.cs * Update Protocol18.cs * Update Entity.cs * EntityCMD Update * Update IMinecraftComHandler.cs * Update Protocol18.cs * Update IMinecraftComHandler.cs * Update McClient.cs * Update IMinecraftComHandler.cs * Update McClient.cs * Update McClient.cs * Update McClient.cs * Update McClient.cs * Update ChatBot.cs * Update McClient.cs * Update Entity.cs * Create EntityPose.cs * Update MinecraftClient.csproj * Update McClient.cs * Update EntityPose.cs * Update Entity.cs * Update McClient.cs * Remove debug line * Update Entitycmd.cs * Update Entity.cs * Update McClient.cs * Update Entity.cs * Update McClient.cs * Update McClient.cs * Update Entity.cs * Update McClient.cs * Update Entitycmd.cs * Update Entitycmd.cs * Update McClient.cs * Update Entitycmd.cs * Update Entitycmd.cs * Update Entity.cs * Update McClient.cs * Update Entitycmd.cs * Update Entitycmd.cs * Update Entitycmd.cs * Update Entitycmd.cs * Update Entitycmd.cs * Update Entitycmd.cs * Crash Fix on Item * Crashes Fix * Update McClient.cs * Crashes fix * Update McClient.cs * Update Entity.cs * Update Entity.cs * Update McClient.cs * Update McClient.cs * Update McClient.cs * Update McClient.cs * Update McClient.cs * Update McClient.cs * Update McClient.cs * Update ChatBot.cs * Update IMinecraftComHandler.cs * Update McClient.cs * Update Protocol18.cs * Update ChatBot.cs * Update IMinecraftComHandler.cs * Update Protocol18.cs * Update McClient.cs * Fix unaddressed issues Co-authored-by: ORelio <oreliogitantispam.l0gin@spamgourmet.com>
This commit is contained in:
parent
a6a5f0c333
commit
c2e2e85063
9 changed files with 207 additions and 31 deletions
|
|
@ -1530,6 +1530,7 @@ namespace MinecraftClient
|
|||
world.Clear();
|
||||
}
|
||||
|
||||
entities.Clear();
|
||||
ClearInventories();
|
||||
DispatchBotEvent(bot => bot.OnRespawn());
|
||||
}
|
||||
|
|
@ -2071,6 +2072,14 @@ namespace MinecraftClient
|
|||
{
|
||||
playerName = onlinePlayers[uuid];
|
||||
playersLatency[playerName] = latency;
|
||||
foreach (KeyValuePair<int, Entity> ent in entities)
|
||||
{
|
||||
if (ent.Value.UUID == uuid && ent.Value.Name == playerName)
|
||||
{
|
||||
ent.Value.Latency = latency;
|
||||
break;
|
||||
}
|
||||
}
|
||||
DispatchBotEvent(bot => bot.OnLatencyUpdate(playerName, uuid, latency));
|
||||
}
|
||||
}
|
||||
|
|
@ -2149,7 +2158,49 @@ namespace MinecraftClient
|
|||
if (entities.ContainsKey(entityID))
|
||||
{
|
||||
entities[entityID].Health = health;
|
||||
DispatchBotEvent(bot => bot.OnEntityHealth(entityID, health));
|
||||
DispatchBotEvent(bot => bot.OnEntityHealth(entities[entityID], health));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the metadata of an entity changed
|
||||
/// </summary>
|
||||
/// <param name="entityID">Entity ID</param>
|
||||
/// <param name="metadata">The metadata of the entity</param>
|
||||
public void OnEntityMetadata(int entityID, Dictionary<int, object> metadata)
|
||||
{
|
||||
if (entities.ContainsKey(entityID))
|
||||
{
|
||||
Entity entity = entities[entityID];
|
||||
try
|
||||
{
|
||||
entity.Metadata = metadata;
|
||||
if (entity.Type.ContainsItem() && metadata.ContainsKey(7) && metadata[7] != null && metadata[7].GetType() == typeof(Item))
|
||||
{
|
||||
try
|
||||
{
|
||||
entity.Item = (Item)metadata[7];
|
||||
}
|
||||
catch
|
||||
{
|
||||
entity.Item = new Item(ItemType.Air, 1, null);
|
||||
}
|
||||
}
|
||||
if (metadata.ContainsKey(6) && metadata[6].GetType() == typeof(Int32))
|
||||
{
|
||||
entity.Pose = (EntityPose)metadata[6];
|
||||
}
|
||||
if (metadata.ContainsKey(2) && metadata.ContainsValue(metadata[2]) && metadata[2].GetType() == typeof(string))
|
||||
{
|
||||
entity.CustomNameJson = metadata[2].ToString();
|
||||
entity.CustomName = ChatParser.ParseText(metadata[2].ToString());
|
||||
}
|
||||
if (metadata.ContainsKey(3) && metadata.ContainsValue(metadata[3]) && metadata[3].GetType() == typeof(bool))
|
||||
{
|
||||
entity.IsCustomNameVisible = (bool)metadata[3];
|
||||
}
|
||||
DispatchBotEvent(bot => bot.OnEntityMetadata(entity, metadata));
|
||||
} catch { }
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue