mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Add entity handling for 1.10 to 1.12.2 (#1195)
* Fix entity type data type for 1.13 below * Add entity handling for 1.10 to 1.12.2 * Update comments for EntityPalette113
This commit is contained in:
parent
a28409043c
commit
e6d34c3cf1
5 changed files with 163 additions and 8 deletions
142
MinecraftClient/Mapping/EntityPalettes/EntityPalette112.cs
Normal file
142
MinecraftClient/Mapping/EntityPalettes/EntityPalette112.cs
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Mapping.EntityPalettes
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines mappings of entitiy IDs for 1.12.2 and below
|
||||
/// Generated by ReinforceZwei using custom script
|
||||
/// Data source: https://github.com/PrismarineJS/minecraft-data
|
||||
/// </summary>
|
||||
public class EntityPalette112 : EntityPalette
|
||||
{
|
||||
private static Dictionary<int, EntityType> mappingsObjects = new Dictionary<int, EntityType>()
|
||||
{
|
||||
// https://wiki.vg/Entity_metadata#Objects
|
||||
{ 1, EntityType.Boat },
|
||||
{ 2, EntityType.Item },
|
||||
{ 3, EntityType.AreaEffectCloud },
|
||||
{ 10, EntityType.Minecart },
|
||||
{ 50, EntityType.Tnt },
|
||||
{ 51, EntityType.EndCrystal },
|
||||
{ 60, EntityType.Arrow },
|
||||
{ 61, EntityType.Snowball },
|
||||
{ 62, EntityType.Egg },
|
||||
{ 63, EntityType.Fireball },
|
||||
{ 64, EntityType.SmallFireball },
|
||||
{ 65, EntityType.EnderPearl },
|
||||
{ 66, EntityType.WitherSkull },
|
||||
{ 67, EntityType.ShulkerBullet },
|
||||
{ 68, EntityType.LlamaSpit },
|
||||
{ 70, EntityType.FallingBlock },
|
||||
{ 71, EntityType.ItemFrame },
|
||||
{ 72, EntityType.EyeOfEnder },
|
||||
{ 73, EntityType.Egg },
|
||||
{ 75, EntityType.Snowball },
|
||||
{ 76, EntityType.FireworkRocket },
|
||||
{ 77, EntityType.LeashKnot },
|
||||
{ 78, EntityType.ArmorStand },
|
||||
{ 79, EntityType.EvokerFangs },
|
||||
{ 90, EntityType.FishingBobber },
|
||||
{ 91, EntityType.SpectralArrow },
|
||||
{ 93, EntityType.DragonFireball },
|
||||
};
|
||||
|
||||
private static Dictionary<int, EntityType> mappingsMobs = new Dictionary<int, EntityType>()
|
||||
{
|
||||
{ 1, EntityType.Item },
|
||||
{ 2, EntityType.ExperienceOrb },
|
||||
{ 3, EntityType.AreaEffectCloud },
|
||||
{ 4, EntityType.ElderGuardian },
|
||||
{ 5, EntityType.WitherSkeleton },
|
||||
{ 6, EntityType.Stray },
|
||||
{ 7, EntityType.Egg },
|
||||
{ 8, EntityType.LeashKnot },
|
||||
{ 9, EntityType.Painting },
|
||||
{ 10, EntityType.Arrow },
|
||||
{ 11, EntityType.Snowball },
|
||||
{ 12, EntityType.Fireball },
|
||||
{ 13, EntityType.SmallFireball },
|
||||
{ 14, EntityType.EnderPearl },
|
||||
{ 15, EntityType.EyeOfEnder },
|
||||
{ 16, EntityType.Potion },
|
||||
{ 17, EntityType.ExperienceBottle },
|
||||
{ 18, EntityType.ItemFrame },
|
||||
{ 19, EntityType.WitherSkull },
|
||||
{ 20, EntityType.Tnt },
|
||||
{ 21, EntityType.FallingBlock },
|
||||
{ 22, EntityType.FireworkRocket },
|
||||
{ 23, EntityType.Husk },
|
||||
{ 24, EntityType.SpectralArrow },
|
||||
{ 25, EntityType.ShulkerBullet },
|
||||
{ 26, EntityType.DragonFireball },
|
||||
{ 27, EntityType.ZombieVillager },
|
||||
{ 28, EntityType.SkeletonHorse },
|
||||
{ 29, EntityType.ZombieHorse },
|
||||
{ 30, EntityType.ArmorStand },
|
||||
{ 31, EntityType.Donkey },
|
||||
{ 32, EntityType.Mule },
|
||||
{ 33, EntityType.EvokerFangs },
|
||||
{ 34, EntityType.Evoker },
|
||||
{ 35, EntityType.Vex },
|
||||
{ 36, EntityType.Vindicator },
|
||||
{ 37, EntityType.Illusioner },
|
||||
{ 40, EntityType.CommandBlockMinecart },
|
||||
{ 41, EntityType.Boat },
|
||||
{ 42, EntityType.Minecart },
|
||||
{ 43, EntityType.ChestMinecart },
|
||||
{ 44, EntityType.FurnaceMinecart },
|
||||
{ 45, EntityType.TntMinecart },
|
||||
{ 46, EntityType.HopperMinecart },
|
||||
{ 47, EntityType.SpawnerMinecart },
|
||||
{ 50, EntityType.Creeper },
|
||||
{ 51, EntityType.Skeleton },
|
||||
{ 52, EntityType.Spider },
|
||||
{ 53, EntityType.Giant },
|
||||
{ 54, EntityType.Zombie },
|
||||
{ 55, EntityType.Slime },
|
||||
{ 56, EntityType.Ghast },
|
||||
{ 57, EntityType.ZombiePigman },
|
||||
{ 58, EntityType.Enderman },
|
||||
{ 59, EntityType.CaveSpider },
|
||||
{ 60, EntityType.Silverfish },
|
||||
{ 61, EntityType.Blaze },
|
||||
{ 62, EntityType.MagmaCube },
|
||||
{ 63, EntityType.EnderDragon },
|
||||
{ 64, EntityType.Wither },
|
||||
{ 65, EntityType.Bat },
|
||||
{ 66, EntityType.Witch },
|
||||
{ 67, EntityType.Endermite },
|
||||
{ 68, EntityType.Guardian },
|
||||
{ 69, EntityType.Shulker },
|
||||
{ 90, EntityType.Pig },
|
||||
{ 91, EntityType.Sheep },
|
||||
{ 92, EntityType.Cow },
|
||||
{ 93, EntityType.Chicken },
|
||||
{ 94, EntityType.Squid },
|
||||
{ 95, EntityType.Wolf },
|
||||
{ 96, EntityType.Mooshroom },
|
||||
{ 97, EntityType.SnowGolem },
|
||||
{ 98, EntityType.Ocelot },
|
||||
{ 99, EntityType.IronGolem },
|
||||
{ 100, EntityType.Horse },
|
||||
{ 101, EntityType.Rabbit },
|
||||
{ 102, EntityType.PolarBear },
|
||||
{ 103, EntityType.Llama },
|
||||
{ 104, EntityType.LlamaSpit },
|
||||
{ 105, EntityType.Parrot },
|
||||
{ 120, EntityType.Villager },
|
||||
{ 200, EntityType.EndCrystal },
|
||||
};
|
||||
|
||||
protected override Dictionary<int, EntityType> GetDict()
|
||||
{
|
||||
return mappingsMobs;
|
||||
}
|
||||
|
||||
protected override Dictionary<int, EntityType> GetDictNonLiving()
|
||||
{
|
||||
return mappingsObjects;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,9 +4,9 @@ using System.Collections.Generic;
|
|||
namespace MinecraftClient.Mapping.EntityPalettes
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines mappings for pre-1.14 entitiy IDs
|
||||
/// Pre-1.14 Minecraft has 2 set of ids: One for non-living objects and one for living mobs
|
||||
/// 1.14+ Minecraft has only one set of ids for all types of entities
|
||||
/// Defines mappings for Minecraft 1.13.
|
||||
/// 1.13 and lower has 2 set of ids: One for non-living objects and one for living mobs
|
||||
/// 1.14+ has only one set of ids for all types of entities
|
||||
/// </summary>
|
||||
public class EntityPalette113 : EntityPalette
|
||||
{
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@
|
|||
<Compile Include="Mapping\CommandBlockFlags.cs" />
|
||||
<Compile Include="Mapping\CommandBlockMode.cs" />
|
||||
<Compile Include="Mapping\Entity.cs" />
|
||||
<Compile Include="Mapping\EntityPalettes\EntityPalette112.cs" />
|
||||
<Compile Include="Mapping\EntityPalettes\EntityPalette113.cs" />
|
||||
<Compile Include="Mapping\EntityPalettes\EntityPalette.cs" />
|
||||
<Compile Include="Mapping\EntityPalettes\EntityPalette114.cs" />
|
||||
|
|
|
|||
|
|
@ -370,7 +370,17 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
entityUUID = ReadNextUUID(cache);
|
||||
}
|
||||
|
||||
EntityType entityType = entityPalette.FromId(ReadNextVarInt(cache), living);
|
||||
EntityType entityType;
|
||||
// Entity type data type change from byte to varint after 1.14
|
||||
if (protocolversion > Protocol18Handler.MC113Version)
|
||||
{
|
||||
entityType = entityPalette.FromId(ReadNextVarInt(cache), living);
|
||||
}
|
||||
else
|
||||
{
|
||||
entityType = entityPalette.FromId(ReadNextByte(cache), living);
|
||||
}
|
||||
|
||||
Double entityX = ReadNextDouble(cache);
|
||||
Double entityY = ReadNextDouble(cache);
|
||||
Double entityZ = ReadNextDouble(cache);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
handler.SetInventoryEnabled(false);
|
||||
}
|
||||
|
||||
if (handler.GetEntityHandlingEnabled() && (protocolversion <= MC1122Version || protocolversion > MC1161Version))
|
||||
if (handler.GetEntityHandlingEnabled() && (protocolversion < MC110Version || protocolversion > MC1161Version))
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Entities are currently not handled for that MC version.");
|
||||
handler.SetEntityHandlingEnabled(false);
|
||||
|
|
@ -102,7 +102,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
else Block.Palette = new Palette112();
|
||||
|
||||
if (protocolversion >= MC114Version)
|
||||
if (protocolversion >= MC113Version)
|
||||
{
|
||||
if (protocolversion > MC1161Version && handler.GetEntityHandlingEnabled())
|
||||
throw new NotImplementedException("Please update entity types handling for this Minecraft version. See EntityType.cs");
|
||||
|
|
@ -110,10 +110,12 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
entityPalette = new EntityPalette116();
|
||||
else if (protocolversion >= MC115Version)
|
||||
entityPalette = new EntityPalette115();
|
||||
else entityPalette = new EntityPalette114();
|
||||
}
|
||||
else if (protocolVersion >= MC114Version)
|
||||
entityPalette = new EntityPalette114();
|
||||
else entityPalette = new EntityPalette113();
|
||||
}
|
||||
else entityPalette = new EntityPalette112();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Separate thread. Network reading loop.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue