mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Fix entity handling crash (#1241)
Fix #1237 * Fix crash * Update Entity.cs * Update Entitycmd.cs * Update McClient.cs
This commit is contained in:
parent
2649e61a88
commit
02e294e3e8
3 changed files with 7 additions and 8 deletions
|
|
@ -144,10 +144,11 @@ namespace MinecraftClient.Commands
|
||||||
string customname = entity2.Value.CustomName;
|
string customname = entity2.Value.CustomName;
|
||||||
EntityPose pose = entity2.Value.Pose;
|
EntityPose pose = entity2.Value.Pose;
|
||||||
EntityType type = entity2.Value.Type;
|
EntityType type = entity2.Value.Type;
|
||||||
|
Item item = entity2.Value.Item;
|
||||||
string location = String.Format("X:{0}, Y:{1}, Z:{2}", Math.Round(entity2.Value.Location.X, 2), Math.Round(entity2.Value.Location.Y, 2), Math.Round(entity2.Value.Location.Y, 2));
|
string location = String.Format("X:{0}, Y:{1}, Z:{2}", Math.Round(entity2.Value.Location.X, 2), Math.Round(entity2.Value.Location.Y, 2), Math.Round(entity2.Value.Location.Y, 2));
|
||||||
|
|
||||||
if (type == EntityType.Item || type == EntityType.ItemFrame || type == Mapping.EntityType.EyeOfEnder || type == Mapping.EntityType.Egg || type == Mapping.EntityType.EnderPearl || type == Mapping.EntityType.Potion || type == Mapping.EntityType.Fireball || type == Mapping.EntityType.FireworkRocket)
|
if (type == EntityType.Item || type == EntityType.ItemFrame || type == Mapping.EntityType.EyeOfEnder || type == Mapping.EntityType.Egg || type == Mapping.EntityType.EnderPearl || type == Mapping.EntityType.Potion || type == Mapping.EntityType.Fireball || type == Mapping.EntityType.FireworkRocket)
|
||||||
response.Add(String.Format(" #{0}: Type: {1}, Item: {2}, Location: {3}", id, type, entity2.Value.Item.Type, location));
|
response.Add(String.Format(" #{0}: Type: {1}, Item: {2}, Location: {3}", id, type, item.Type, location));
|
||||||
else if (type == Mapping.EntityType.Player && !String.IsNullOrEmpty(nickname))
|
else if (type == Mapping.EntityType.Player && !String.IsNullOrEmpty(nickname))
|
||||||
response.Add(String.Format(" #{0}: Type: {1}, Nickname: §8{2}§8, Latency: {3}, Health: {4}, Pose: {5}, Location: {6}", id, type, nickname, latency, health, pose, location));
|
response.Add(String.Format(" #{0}: Type: {1}, Nickname: §8{2}§8, Latency: {3}, Health: {4}, Pose: {5}, Location: {6}", id, type, nickname, latency, health, pose, location));
|
||||||
else if (type == Mapping.EntityType.Player && !String.IsNullOrEmpty(customname))
|
else if (type == Mapping.EntityType.Player && !String.IsNullOrEmpty(customname))
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,7 @@ namespace MinecraftClient.Mapping
|
||||||
this.Location = location;
|
this.Location = location;
|
||||||
this.Health = 1.0f;
|
this.Health = 1.0f;
|
||||||
this.Equipment = new Dictionary<int, Item>();
|
this.Equipment = new Dictionary<int, Item>();
|
||||||
|
this.Item = new Item(ItemType.Air, 0, null);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new entity based on Entity ID, Entity Type, location, name and UUID
|
/// Create a new entity based on Entity ID, Entity Type, location, name and UUID
|
||||||
|
|
@ -110,6 +111,7 @@ namespace MinecraftClient.Mapping
|
||||||
this.Name = name;
|
this.Name = name;
|
||||||
this.Health = 1.0f;
|
this.Health = 1.0f;
|
||||||
this.Equipment = new Dictionary<int, Item>();
|
this.Equipment = new Dictionary<int, Item>();
|
||||||
|
this.Item = new Item(ItemType.Air, 0, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2180,14 +2180,10 @@ namespace MinecraftClient
|
||||||
entity.Metadata = metadata;
|
entity.Metadata = metadata;
|
||||||
if (entity.Type.ContainsItem() && metadata.ContainsKey(7) && metadata[7] != null && metadata[7].GetType() == typeof(Item))
|
if (entity.Type.ContainsItem() && metadata.ContainsKey(7) && metadata[7] != null && metadata[7].GetType() == typeof(Item))
|
||||||
{
|
{
|
||||||
try
|
Item item = (Item)metadata[7];
|
||||||
{
|
if (item == null)
|
||||||
entity.Item = (Item)metadata[7];
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
entity.Item = new Item(ItemType.Air, 0, null);
|
entity.Item = new Item(ItemType.Air, 0, null);
|
||||||
}
|
else entity.Item = item;
|
||||||
}
|
}
|
||||||
if (metadata.ContainsKey(6) && metadata[6] != null && metadata[6].GetType() == typeof(Int32))
|
if (metadata.ContainsKey(6) && metadata[6] != null && metadata[6].GetType() == typeof(Int32))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue