Implement entity types (#1001)

Implement palette generation and investigate palette changes between
versions. Turns out 1.13- has legacy IDs, 1.14 switches to entity
palette and 1.15 refreshes the whole palette just to insert Bee.

Also refactor entity handling code here and there.
This commit is contained in:
ORelio 2020-05-24 18:21:22 +02:00
parent 5b0b0c9cc3
commit bd85c46663
27 changed files with 1113 additions and 259 deletions

View file

@ -21,60 +21,15 @@ namespace MinecraftClient.Mapping
public Guid UUID;
/// <summary>
/// Entity type determined by Minecraft Console Client
/// Entity type
/// </summary>
public EntityType Type;
/// <summary>
/// Entity type ID (more precise than Type, but may change between Minecraft versions)
/// </summary>
public int TypeID;
/// <summary>
/// Entity location in the Minecraft world
/// </summary>
public Location Location;
/// <summary>
/// Create a new entity based on Entity ID and location
/// </summary>
/// <param name="ID">Entity ID</param>
/// <param name="location">Entity location</param>
public Entity(int ID, Location location)
{
this.ID = ID;
this.Location = location;
}
/// <summary>
/// Create a new entity based on Entity ID, Entity Type and location
/// </summary>
/// <param name="ID">Entity ID</param>
/// <param name="TypeID">Entity Type ID</param>
/// <param name="location">Entity location</param>
public Entity(int ID, int TypeID, Location location)
{
this.ID = ID;
this.TypeID = TypeID;
this.Location = location;
}
/// <summary>
/// Create a new entity based on Entity ID, Entity Type, location, and UUID
/// </summary>
/// <param name="ID">Entity ID</param>
/// <param name="TypeID">Entity Type ID</param>
/// <param name="type">Entity Type Enum</param>
/// <param name="location">Entity location</param>
public Entity(int ID, int TypeID, EntityType type, Location location, Guid uuid)
{
this.ID = ID;
this.TypeID = TypeID;
this.Type = type;
this.Location = location;
this.UUID = uuid;
}
/// <summary>
/// Create a new entity based on Entity ID, Entity Type and location
/// </summary>
@ -100,41 +55,5 @@ namespace MinecraftClient.Mapping
this.Location = location;
this.UUID = uuid;
}
/// <summary>
/// Return TRUE if the Entity is an hostile mob
/// </summary>
/// <remarks>New mobs added in newer Minecraft versions might be absent from the list</remarks>
/// <returns>TRUE if hostile</returns>
public bool IsHostile()
{
switch (TypeID)
{
case 5: return true; // Blaze;
case 12: return true; // Creeper
case 16: return true; // Drowned
case 23: return true; // Evoker
case 29: return true; // Ghast
case 31: return true; // Guardian
case 33: return true; // Husk
case 41: return true; // Magma Cube
case 57: return true; // Zombie Pigman
case 63: return true; // Shulker
case 65: return true; // Silverfish
case 66: return true; // Skeleton
case 68: return true; // Slime
case 75: return true; // Stray
case 84: return true; // Vex
case 87: return true; // Vindicator
case 88: return true; // Pillager
case 90: return true; // Witch
case 92: return true; // Wither Skeleton
case 95: return true; // Zombie
case 97: return true; // Zombie Villager
case 98: return true; // Phantom
case 99: return true; // Ravager
default: return false;
}
}
}
}