Add health information for entity

This commit is contained in:
ReinforceZwei 2020-08-14 21:22:19 +08:00
parent 44270ab394
commit 1f93fdbab5
2 changed files with 15 additions and 1 deletions

View file

@ -33,6 +33,11 @@ namespace MinecraftClient.Mapping
/// </summary>
public Location Location;
/// <summary>
/// Health of the entity
/// </summary>
public float Health;
/// <summary>
/// Create a new entity based on Entity ID, Entity Type and location
/// </summary>
@ -44,6 +49,7 @@ namespace MinecraftClient.Mapping
this.ID = ID;
this.Type = type;
this.Location = location;
this.Health = 0;
}
/// <summary>
/// Create a new entity based on Entity ID, Entity Type, location, name and UUID
@ -60,6 +66,7 @@ namespace MinecraftClient.Mapping
this.Location = location;
this.UUID = uuid;
this.Name = name;
this.Health = 0;
}
}
}

View file

@ -2119,7 +2119,14 @@ namespace MinecraftClient
/// <param name="metadata">Metadata</param>
public void OnEntityMetadata(int entityID, Dictionary<int, object> metadata)
{
if (entities.ContainsKey(entityID))
{
// Get health data for an entity
if (metadata.ContainsKey(8) && metadata[8].GetType() == typeof(float))
{
entities[entityID].Health = (float)metadata[8];
}
}
}
#endregion
}