mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Updated the protocol for 1.16/1.16.1. Fixed Auto Attack (Added a new field (sneaking) to the Interact Entity event (Only 1.16 and above)). Added Entity Pallete for 1.16/1.16.1.
This commit is contained in:
parent
e542612e76
commit
a58e975630
6 changed files with 173 additions and 33 deletions
126
MinecraftClient/Mapping/EntityPalettes/EntityPalette116.cs
Normal file
126
MinecraftClient/Mapping/EntityPalettes/EntityPalette116.cs
Normal file
|
|
@ -0,0 +1,126 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace MinecraftClient.Mapping.EntityPalettes
|
||||||
|
{
|
||||||
|
public class EntityPalette116 : EntityPalette
|
||||||
|
{
|
||||||
|
private static Dictionary<int, EntityType> mappings = new Dictionary<int, EntityType>();
|
||||||
|
|
||||||
|
static EntityPalette116()
|
||||||
|
{
|
||||||
|
mappings[0] = EntityType.AreaEffectCloud;
|
||||||
|
mappings[1] = EntityType.ArmorStand;
|
||||||
|
mappings[2] = EntityType.Arrow;
|
||||||
|
mappings[3] = EntityType.Bat;
|
||||||
|
mappings[4] = EntityType.Bee;
|
||||||
|
mappings[5] = EntityType.Blaze;
|
||||||
|
mappings[6] = EntityType.Boat;
|
||||||
|
mappings[7] = EntityType.Cat;
|
||||||
|
mappings[8] = EntityType.CaveSpider;
|
||||||
|
mappings[9] = EntityType.Chicken;
|
||||||
|
mappings[10] = EntityType.Cod;
|
||||||
|
mappings[11] = EntityType.Cow;
|
||||||
|
mappings[12] = EntityType.Creeper;
|
||||||
|
mappings[13] = EntityType.Dolphin;
|
||||||
|
mappings[14] = EntityType.Donkey;
|
||||||
|
mappings[15] = EntityType.DragonFireball;
|
||||||
|
mappings[16] = EntityType.Drowned;
|
||||||
|
mappings[17] = EntityType.ElderGuardian;
|
||||||
|
mappings[18] = EntityType.EndCrystal;
|
||||||
|
mappings[19] = EntityType.EnderDragon;
|
||||||
|
mappings[20] = EntityType.Enderman;
|
||||||
|
mappings[21] = EntityType.Endermite;
|
||||||
|
mappings[22] = EntityType.Evoker;
|
||||||
|
mappings[23] = EntityType.EvokerFangs;
|
||||||
|
mappings[24] = EntityType.ExperienceOrb;
|
||||||
|
mappings[25] = EntityType.EyeOfEnder;
|
||||||
|
mappings[26] = EntityType.FallingBlock;
|
||||||
|
mappings[27] = EntityType.FireworkRocket;
|
||||||
|
mappings[28] = EntityType.Fox;
|
||||||
|
mappings[29] = EntityType.Ghast;
|
||||||
|
mappings[30] = EntityType.Giant;
|
||||||
|
mappings[31] = EntityType.Guardian;
|
||||||
|
mappings[32] = EntityType.Hoglin;
|
||||||
|
mappings[33] = EntityType.Horse;
|
||||||
|
mappings[34] = EntityType.Husk;
|
||||||
|
mappings[35] = EntityType.Illusioner;
|
||||||
|
mappings[36] = EntityType.IronGolem;
|
||||||
|
mappings[37] = EntityType.Item;
|
||||||
|
mappings[38] = EntityType.ItemFrame;
|
||||||
|
mappings[39] = EntityType.Fireball;
|
||||||
|
mappings[40] = EntityType.LeashKnot;
|
||||||
|
mappings[41] = EntityType.LightningBolt;
|
||||||
|
mappings[42] = EntityType.Llama;
|
||||||
|
mappings[43] = EntityType.LlamaSpit;
|
||||||
|
mappings[44] = EntityType.MagmaCube;
|
||||||
|
mappings[45] = EntityType.Minecart;
|
||||||
|
mappings[46] = EntityType.ChestMinecart;
|
||||||
|
mappings[47] = EntityType.CommandBlockMinecart;
|
||||||
|
mappings[48] = EntityType.FurnaceMinecart;
|
||||||
|
mappings[49] = EntityType.HopperMinecart;
|
||||||
|
mappings[50] = EntityType.SpawnerMinecart;
|
||||||
|
mappings[51] = EntityType.TntMinecart;
|
||||||
|
mappings[52] = EntityType.Mule;
|
||||||
|
mappings[53] = EntityType.Mooshroom;
|
||||||
|
mappings[54] = EntityType.Ocelot;
|
||||||
|
mappings[55] = EntityType.Painting;
|
||||||
|
mappings[56] = EntityType.Panda;
|
||||||
|
mappings[57] = EntityType.Parrot;
|
||||||
|
mappings[58] = EntityType.Phantom;
|
||||||
|
mappings[59] = EntityType.Pig;
|
||||||
|
mappings[60] = EntityType.Piglin;
|
||||||
|
mappings[61] = EntityType.Pillager;
|
||||||
|
mappings[62] = EntityType.PolarBear;
|
||||||
|
mappings[63] = EntityType.Tnt;
|
||||||
|
mappings[64] = EntityType.Pufferfish;
|
||||||
|
mappings[65] = EntityType.Rabbit;
|
||||||
|
mappings[66] = EntityType.Ravager;
|
||||||
|
mappings[67] = EntityType.Salmon;
|
||||||
|
mappings[68] = EntityType.Sheep;
|
||||||
|
mappings[69] = EntityType.Shulker;
|
||||||
|
mappings[70] = EntityType.ShulkerBullet;
|
||||||
|
mappings[71] = EntityType.Silverfish;
|
||||||
|
mappings[72] = EntityType.Skeleton;
|
||||||
|
mappings[73] = EntityType.SkeletonHorse;
|
||||||
|
mappings[74] = EntityType.Slime;
|
||||||
|
mappings[75] = EntityType.SmallFireball;
|
||||||
|
mappings[76] = EntityType.SnowGolem;
|
||||||
|
mappings[77] = EntityType.Snowball;
|
||||||
|
mappings[78] = EntityType.SpectralArrow;
|
||||||
|
mappings[79] = EntityType.Spider;
|
||||||
|
mappings[80] = EntityType.Squid;
|
||||||
|
mappings[81] = EntityType.Stray;
|
||||||
|
mappings[82] = EntityType.Strider;
|
||||||
|
mappings[83] = EntityType.Egg;
|
||||||
|
mappings[84] = EntityType.EnderPearl;
|
||||||
|
mappings[85] = EntityType.ExperienceBottle;
|
||||||
|
mappings[86] = EntityType.Potion;
|
||||||
|
mappings[87] = EntityType.Trident;
|
||||||
|
mappings[88] = EntityType.TraderLlama;
|
||||||
|
mappings[89] = EntityType.TropicalFish;
|
||||||
|
mappings[90] = EntityType.Turtle;
|
||||||
|
mappings[91] = EntityType.Vex;
|
||||||
|
mappings[92] = EntityType.Villager;
|
||||||
|
mappings[93] = EntityType.Vindicator;
|
||||||
|
mappings[94] = EntityType.WanderingTrader;
|
||||||
|
mappings[95] = EntityType.Witch;
|
||||||
|
mappings[96] = EntityType.Wither;
|
||||||
|
mappings[97] = EntityType.WitherSkeleton;
|
||||||
|
mappings[98] = EntityType.WitherSkull;
|
||||||
|
mappings[99] = EntityType.Wolf;
|
||||||
|
mappings[100] = EntityType.Zoglin;
|
||||||
|
mappings[101] = EntityType.Zombie;
|
||||||
|
mappings[102] = EntityType.ZombieHorse;
|
||||||
|
mappings[103] = EntityType.ZombieVillager;
|
||||||
|
mappings[104] = EntityType.ZombiePigman;
|
||||||
|
mappings[105] = EntityType.Player;
|
||||||
|
mappings[106] = EntityType.FishingBobber;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Dictionary<int, EntityType> GetDict()
|
||||||
|
{
|
||||||
|
return mappings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,17 +1,5 @@
|
||||||
namespace MinecraftClient.Mapping
|
namespace MinecraftClient.Mapping
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Represents Minecraft Entity Types
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// Generated from registries.json using EntityPaletteGenerator.cs.
|
|
||||||
/// Typical steps to handle new entity IDs for newer Minecraft versions:
|
|
||||||
/// 1. Generate registries.json using data reporting on Vanilla Minecraft (https://wiki.vg/Data_Generators)
|
|
||||||
/// 2. Generate temporary EntityTypeXXX.cs and EntityPaletteXXX.cs using EntityPaletteGenerator.cs
|
|
||||||
/// 3. Perform a diff with existing versions, add missing entries in EntityType.cs and EntityTypeExtensions.cs
|
|
||||||
/// 4. If existing entity IDs were not randomized by Mojang, simply add missing entries to the latest existing EntityPaletteXXX.cs
|
|
||||||
/// 5. If existing entity IDs were randomized, add a new palette as EntityPaletteXXX.cs into the codebase (worst case)
|
|
||||||
/// </remarks>
|
|
||||||
public enum EntityType
|
public enum EntityType
|
||||||
{
|
{
|
||||||
AreaEffectCloud,
|
AreaEffectCloud,
|
||||||
|
|
@ -27,8 +15,8 @@ namespace MinecraftClient.Mapping
|
||||||
Cod,
|
Cod,
|
||||||
Cow,
|
Cow,
|
||||||
Creeper,
|
Creeper,
|
||||||
Donkey,
|
|
||||||
Dolphin,
|
Dolphin,
|
||||||
|
Donkey,
|
||||||
DragonFireball,
|
DragonFireball,
|
||||||
Drowned,
|
Drowned,
|
||||||
ElderGuardian,
|
ElderGuardian,
|
||||||
|
|
@ -36,8 +24,8 @@ namespace MinecraftClient.Mapping
|
||||||
EnderDragon,
|
EnderDragon,
|
||||||
Enderman,
|
Enderman,
|
||||||
Endermite,
|
Endermite,
|
||||||
EvokerFangs,
|
|
||||||
Evoker,
|
Evoker,
|
||||||
|
EvokerFangs,
|
||||||
ExperienceOrb,
|
ExperienceOrb,
|
||||||
EyeOfEnder,
|
EyeOfEnder,
|
||||||
FallingBlock,
|
FallingBlock,
|
||||||
|
|
@ -46,13 +34,16 @@ namespace MinecraftClient.Mapping
|
||||||
Ghast,
|
Ghast,
|
||||||
Giant,
|
Giant,
|
||||||
Guardian,
|
Guardian,
|
||||||
|
Hoglin,
|
||||||
Horse,
|
Horse,
|
||||||
Husk,
|
Husk,
|
||||||
Illusioner,
|
Illusioner,
|
||||||
|
IronGolem,
|
||||||
Item,
|
Item,
|
||||||
ItemFrame,
|
ItemFrame,
|
||||||
Fireball,
|
Fireball,
|
||||||
LeashKnot,
|
LeashKnot,
|
||||||
|
LightningBolt,
|
||||||
Llama,
|
Llama,
|
||||||
LlamaSpit,
|
LlamaSpit,
|
||||||
MagmaCube,
|
MagmaCube,
|
||||||
|
|
@ -69,12 +60,15 @@ namespace MinecraftClient.Mapping
|
||||||
Painting,
|
Painting,
|
||||||
Panda,
|
Panda,
|
||||||
Parrot,
|
Parrot,
|
||||||
|
Phantom,
|
||||||
Pig,
|
Pig,
|
||||||
Pufferfish,
|
Piglin,
|
||||||
ZombiePigman,
|
Pillager,
|
||||||
PolarBear,
|
PolarBear,
|
||||||
Tnt,
|
Tnt,
|
||||||
|
Pufferfish,
|
||||||
Rabbit,
|
Rabbit,
|
||||||
|
Ravager,
|
||||||
Salmon,
|
Salmon,
|
||||||
Sheep,
|
Sheep,
|
||||||
Shulker,
|
Shulker,
|
||||||
|
|
@ -90,31 +84,29 @@ namespace MinecraftClient.Mapping
|
||||||
Spider,
|
Spider,
|
||||||
Squid,
|
Squid,
|
||||||
Stray,
|
Stray,
|
||||||
TraderLlama,
|
Strider,
|
||||||
TropicalFish,
|
|
||||||
Turtle,
|
|
||||||
Egg,
|
Egg,
|
||||||
EnderPearl,
|
EnderPearl,
|
||||||
ExperienceBottle,
|
ExperienceBottle,
|
||||||
Potion,
|
Potion,
|
||||||
Trident,
|
Trident,
|
||||||
|
TraderLlama,
|
||||||
|
TropicalFish,
|
||||||
|
Turtle,
|
||||||
Vex,
|
Vex,
|
||||||
Villager,
|
Villager,
|
||||||
IronGolem,
|
|
||||||
Vindicator,
|
Vindicator,
|
||||||
Pillager,
|
|
||||||
WanderingTrader,
|
WanderingTrader,
|
||||||
Witch,
|
Witch,
|
||||||
Wither,
|
Wither,
|
||||||
WitherSkeleton,
|
WitherSkeleton,
|
||||||
WitherSkull,
|
WitherSkull,
|
||||||
Wolf,
|
Wolf,
|
||||||
|
Zoglin,
|
||||||
Zombie,
|
Zombie,
|
||||||
ZombieHorse,
|
ZombieHorse,
|
||||||
ZombieVillager,
|
ZombieVillager,
|
||||||
Phantom,
|
ZombiePigman,
|
||||||
Ravager,
|
|
||||||
LightningBolt,
|
|
||||||
Player,
|
Player,
|
||||||
FishingBobber,
|
FishingBobber,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,7 @@
|
||||||
<Compile Include="Mapping\EntityPalettes\EntityPalette.cs" />
|
<Compile Include="Mapping\EntityPalettes\EntityPalette.cs" />
|
||||||
<Compile Include="Mapping\EntityPalettes\EntityPalette114.cs" />
|
<Compile Include="Mapping\EntityPalettes\EntityPalette114.cs" />
|
||||||
<Compile Include="Mapping\EntityPalettes\EntityPalette115.cs" />
|
<Compile Include="Mapping\EntityPalettes\EntityPalette115.cs" />
|
||||||
|
<Compile Include="Mapping\EntityPalettes\EntityPalette116.cs" />
|
||||||
<Compile Include="Mapping\EntityType.cs" />
|
<Compile Include="Mapping\EntityType.cs" />
|
||||||
<Compile Include="Mapping\EntityPalettes\EntityPaletteGenerator.cs" />
|
<Compile Include="Mapping\EntityPalettes\EntityPaletteGenerator.cs" />
|
||||||
<Compile Include="Mapping\EntityTypeExtensions.cs" />
|
<Compile Include="Mapping\EntityTypeExtensions.cs" />
|
||||||
|
|
|
||||||
|
|
@ -671,6 +671,18 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
return bytes.ToArray();
|
return bytes.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Build an boolean for sending over the network
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="paramBool">Boolean to encode</param>
|
||||||
|
/// <returns>Byte array for this boolean</returns>
|
||||||
|
public byte[] GetVarBool(bool paramBool)
|
||||||
|
{
|
||||||
|
List<byte> bytes = new List<byte>();
|
||||||
|
bytes.Add((byte)Convert.ToByte(paramBool));
|
||||||
|
return bytes.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get byte array representing a long integer
|
/// Get byte array representing a long integer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
handler.SetInventoryEnabled(false);
|
handler.SetInventoryEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handler.GetEntityHandlingEnabled() && (protocolversion <= MC1122Version || protocolversion > MC1152Version))
|
if (handler.GetEntityHandlingEnabled() && (protocolversion <= MC1122Version || protocolversion > MC1161Version))
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLineFormatted("§8Entities are currently not handled for that MC version.");
|
ConsoleIO.WriteLineFormatted("§8Entities are currently not handled for that MC version.");
|
||||||
handler.SetEntityHandlingEnabled(false);
|
handler.SetEntityHandlingEnabled(false);
|
||||||
|
|
@ -104,11 +104,13 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
if (protocolversion >= MC114Version)
|
if (protocolversion >= MC114Version)
|
||||||
{
|
{
|
||||||
if (protocolversion > MC1152Version && handler.GetEntityHandlingEnabled())
|
if (protocolversion > MC1161Version && handler.GetEntityHandlingEnabled())
|
||||||
throw new NotImplementedException("Please update entity types handling for this Minecraft version. See EntityType.cs");
|
throw new NotImplementedException("Please update entity types handling for this Minecraft version. See EntityType.cs");
|
||||||
if (protocolversion >= MC115Version)
|
if (protocolversion < MC115Version)
|
||||||
entityPalette = new EntityPalette115();
|
entityPalette = new EntityPalette114();
|
||||||
else entityPalette = new EntityPalette114();
|
if (protocolversion > MC115Version)
|
||||||
|
entityPalette = new EntityPalette116();
|
||||||
|
else entityPalette = new EntityPalette115();
|
||||||
}
|
}
|
||||||
else entityPalette = new EntityPalette113();
|
else entityPalette = new EntityPalette113();
|
||||||
}
|
}
|
||||||
|
|
@ -1436,6 +1438,13 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
List<byte> fields = new List<byte>();
|
List<byte> fields = new List<byte>();
|
||||||
fields.AddRange(dataTypes.GetVarInt(EntityID));
|
fields.AddRange(dataTypes.GetVarInt(EntityID));
|
||||||
fields.AddRange(dataTypes.GetVarInt(type));
|
fields.AddRange(dataTypes.GetVarInt(type));
|
||||||
|
|
||||||
|
// Is player Sneaking (Only 1.16 and above)
|
||||||
|
// Currently hardcoded to false
|
||||||
|
// TODO: Update to reflect the real player state
|
||||||
|
if (protocolversion >= MC116Version)
|
||||||
|
fields.AddRange(dataTypes.GetVarBool(false));
|
||||||
|
|
||||||
SendPacket(PacketOutgoingType.InteractEntity, fields);
|
SendPacket(PacketOutgoingType.InteractEntity, fields);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -385,9 +385,9 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
case 0x29: return PacketIncomingType.EntityPositionAndRotation;
|
case 0x29: return PacketIncomingType.EntityPositionAndRotation;
|
||||||
case 0x58: return PacketIncomingType.EntityProperties;
|
case 0x58: return PacketIncomingType.EntityProperties;
|
||||||
case 0x56: return PacketIncomingType.EntityTeleport;
|
case 0x56: return PacketIncomingType.EntityTeleport;
|
||||||
case 0x46: return PacketIncomingType.EntityVelocity;
|
case 0x46: return PacketIncomingType.EntityVelocity; // This is maybe entity moving, not sure
|
||||||
case 0x47: return PacketIncomingType.EntityEquipment;
|
case 0x47: return PacketIncomingType.EntityEquipment;
|
||||||
case 0x5A: return PacketIncomingType.EntityEffect;
|
case 0x59: return PacketIncomingType.EntityEffect;
|
||||||
case 0x4E: return PacketIncomingType.TimeUpdate;
|
case 0x4E: return PacketIncomingType.TimeUpdate;
|
||||||
case 0x49: return PacketIncomingType.UpdateHealth;
|
case 0x49: return PacketIncomingType.UpdateHealth;
|
||||||
case 0x48: return PacketIncomingType.SetExperience;
|
case 0x48: return PacketIncomingType.SetExperience;
|
||||||
|
|
@ -605,12 +605,12 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
case PacketOutgoingType.UseItem: return 0x2E;
|
case PacketOutgoingType.UseItem: return 0x2E;
|
||||||
case PacketOutgoingType.ClickWindow: return 0x09;
|
case PacketOutgoingType.ClickWindow: return 0x09;
|
||||||
case PacketOutgoingType.CloseWindow: return 0x0A;
|
case PacketOutgoingType.CloseWindow: return 0x0A;
|
||||||
case PacketOutgoingType.PlayerBlockPlacement: return 0x2C;
|
case PacketOutgoingType.PlayerBlockPlacement: return 0x2D;
|
||||||
case PacketOutgoingType.CreativeInventoryAction: return 0x27;
|
case PacketOutgoingType.CreativeInventoryAction: return 0x27;
|
||||||
case PacketOutgoingType.Animation: return 0x2B;
|
case PacketOutgoingType.Animation: return 0x2B;
|
||||||
case PacketOutgoingType.PlayerDigging: return 0x1B;
|
case PacketOutgoingType.PlayerDigging: return 0x1B;
|
||||||
case PacketOutgoingType.UpdateSign: return 0x2A;
|
case PacketOutgoingType.UpdateSign: return 0x2A;
|
||||||
case PacketOutgoingType.UpdateCommandBlock: return 0x24;
|
case PacketOutgoingType.UpdateCommandBlock: return 0x25;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue