2020-05-26 00:16:53 +05:00
|
|
|
using System;
|
2020-03-23 19:59:00 +08:00
|
|
|
using System.Collections.Generic;
|
2020-08-20 21:36:50 +05:00
|
|
|
using MinecraftClient.Inventory;
|
2020-03-23 19:59:00 +08:00
|
|
|
|
|
|
|
|
namespace MinecraftClient.Mapping
|
|
|
|
|
{
|
2020-03-28 00:48:41 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Represents an entity evolving into a Minecraft world
|
|
|
|
|
/// </summary>
|
2020-03-23 19:59:00 +08:00
|
|
|
public class Entity
|
|
|
|
|
{
|
2020-03-28 00:48:41 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// ID of the entity on the Minecraft server
|
|
|
|
|
/// </summary>
|
2020-03-23 19:59:00 +08:00
|
|
|
public int ID;
|
2020-03-28 00:48:41 +01:00
|
|
|
|
2020-04-30 16:25:10 -05:00
|
|
|
/// <summary>
|
|
|
|
|
/// UUID of the entity if it is a player.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Guid UUID;
|
|
|
|
|
|
2020-05-26 00:16:53 +05:00
|
|
|
/// <summary>
|
|
|
|
|
/// Nickname of the entity if it is a player.
|
|
|
|
|
/// </summary>
|
2022-08-15 23:55:44 +08:00
|
|
|
public string? Name;
|
2022-10-02 18:31:08 +08:00
|
|
|
|
2020-08-20 21:36:50 +05:00
|
|
|
/// <summary>
|
|
|
|
|
/// CustomName of the entity.
|
|
|
|
|
/// </summary>
|
2022-10-02 18:31:08 +08:00
|
|
|
public string? CustomNameJson;
|
|
|
|
|
|
2020-08-20 21:36:50 +05:00
|
|
|
/// <summary>
|
|
|
|
|
/// IsCustomNameVisible of the entity.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsCustomNameVisible;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CustomName of the entity.
|
|
|
|
|
/// </summary>
|
2022-10-02 18:31:08 +08:00
|
|
|
public string? CustomName;
|
|
|
|
|
|
2020-08-20 21:36:50 +05:00
|
|
|
/// <summary>
|
|
|
|
|
/// Latency of the entity if it is a player.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Latency;
|
2020-05-26 00:16:53 +05:00
|
|
|
|
2020-03-28 00:48:41 +01:00
|
|
|
/// <summary>
|
2020-05-24 18:21:22 +02:00
|
|
|
/// Entity type
|
2020-03-28 00:48:41 +01:00
|
|
|
/// </summary>
|
2020-03-26 15:01:42 +08:00
|
|
|
public EntityType Type;
|
2020-03-28 00:48:41 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Entity location in the Minecraft world
|
|
|
|
|
/// </summary>
|
2020-03-23 19:59:00 +08:00
|
|
|
public Location Location;
|
2020-03-28 00:48:41 +01:00
|
|
|
|
2021-03-13 22:23:58 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// Entity head yaw
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>Untested</remarks>
|
|
|
|
|
public float Yaw = 0;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Entity head pitch
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>Untested</remarks>
|
|
|
|
|
public float Pitch = 0;
|
|
|
|
|
|
2022-08-15 23:55:44 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// Used in Item Frame, Falling Block and Fishing Float.
|
|
|
|
|
/// See https://wiki.vg/Object_Data for details.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>Untested</remarks>
|
|
|
|
|
public int ObjectData = -1;
|
|
|
|
|
|
2020-08-15 21:32:46 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// Health of the entity
|
|
|
|
|
/// </summary>
|
|
|
|
|
public float Health;
|
2022-10-02 18:31:08 +08:00
|
|
|
|
2020-08-20 21:36:50 +05:00
|
|
|
/// <summary>
|
|
|
|
|
/// Item of the entity if ItemFrame or Item
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Item Item;
|
2022-10-02 18:31:08 +08:00
|
|
|
|
2020-08-20 21:36:50 +05:00
|
|
|
/// <summary>
|
|
|
|
|
/// Entity pose in the Minecraft world
|
|
|
|
|
/// </summary>
|
|
|
|
|
public EntityPose Pose;
|
2022-10-02 18:31:08 +08:00
|
|
|
|
2020-08-20 21:36:50 +05:00
|
|
|
/// <summary>
|
|
|
|
|
/// Entity metadata
|
|
|
|
|
/// </summary>
|
2022-10-02 18:31:08 +08:00
|
|
|
public Dictionary<int, object?>? Metadata;
|
2020-08-26 21:58:45 +05:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Entity equipment
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Dictionary<int, Item> Equipment;
|
|
|
|
|
|
2020-03-28 00:48:41 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Create a new entity based on Entity ID, Entity Type and location
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ID">Entity ID</param>
|
|
|
|
|
/// <param name="type">Entity Type Enum</param>
|
|
|
|
|
/// <param name="location">Entity location</param>
|
2020-03-26 15:01:42 +08:00
|
|
|
public Entity(int ID, EntityType type, Location location)
|
|
|
|
|
{
|
|
|
|
|
this.ID = ID;
|
2022-10-02 18:31:08 +08:00
|
|
|
Type = type;
|
|
|
|
|
Location = location;
|
|
|
|
|
Health = 1.0f;
|
|
|
|
|
Equipment = new Dictionary<int, Item>();
|
|
|
|
|
Item = new Item(ItemType.Air, 0, null);
|
2020-03-26 15:01:42 +08:00
|
|
|
}
|
2021-03-13 22:23:58 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Create a new entity based on Entity ID, Entity Type and location
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ID">Entity ID</param>
|
|
|
|
|
/// <param name="type">Entity Type Enum</param>
|
|
|
|
|
/// <param name="location">Entity location</param>
|
2022-08-15 23:55:44 +08:00
|
|
|
public Entity(int ID, EntityType type, Location location, byte yaw, byte pitch, int objectData)
|
2021-03-13 22:23:58 +08:00
|
|
|
{
|
|
|
|
|
this.ID = ID;
|
2022-10-02 18:31:08 +08:00
|
|
|
Type = type;
|
|
|
|
|
Location = location;
|
|
|
|
|
Health = 1.0f;
|
|
|
|
|
Equipment = new Dictionary<int, Item>();
|
|
|
|
|
Item = new Item(ItemType.Air, 0, null);
|
|
|
|
|
Yaw = yaw * (1 / 256) * 360; // to angle in 360 degree
|
|
|
|
|
Pitch = pitch * (1 / 256) * 360;
|
|
|
|
|
ObjectData = objectData;
|
2021-03-13 22:23:58 +08:00
|
|
|
}
|
|
|
|
|
|
2020-04-30 16:25:10 -05:00
|
|
|
/// <summary>
|
2020-05-25 21:39:24 +02:00
|
|
|
/// Create a new entity based on Entity ID, Entity Type, location, name and UUID
|
2020-04-30 16:25:10 -05:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ID">Entity ID</param>
|
|
|
|
|
/// <param name="type">Entity Type Enum</param>
|
|
|
|
|
/// <param name="location">Entity location</param>
|
2020-05-26 00:16:53 +05:00
|
|
|
/// <param name="uuid">Player uuid</param>
|
2020-05-25 21:39:24 +02:00
|
|
|
/// <param name="name">Player name</param>
|
2022-09-09 16:13:25 +08:00
|
|
|
public Entity(int ID, EntityType type, Location location, Guid uuid, string? name, byte yaw, byte pitch)
|
2020-04-30 16:25:10 -05:00
|
|
|
{
|
|
|
|
|
this.ID = ID;
|
2022-10-02 18:31:08 +08:00
|
|
|
Type = type;
|
|
|
|
|
Location = location;
|
|
|
|
|
UUID = uuid;
|
|
|
|
|
Name = name;
|
|
|
|
|
Health = 1.0f;
|
|
|
|
|
Equipment = new Dictionary<int, Item>();
|
|
|
|
|
Item = new Item(ItemType.Air, 0, null);
|
|
|
|
|
Yaw = yaw * (1 / 256) * 360; // to angle in 360 degree
|
|
|
|
|
Pitch = pitch * (1 / 256) * 360;
|
2020-04-30 16:25:10 -05:00
|
|
|
}
|
2020-03-23 19:59:00 +08:00
|
|
|
}
|
|
|
|
|
}
|