Added Item, Entity, Block, Material Palettes for 1.19. Fixed SpawnEntity and disabled BlockChange packet on 1.19 to prevent crashing until it's fixed. Enabled Entity and Inventory handling.

This commit is contained in:
Milutinke 2022-08-22 19:46:30 +02:00
parent e150bd569b
commit d7310e477b
20 changed files with 3161 additions and 218 deletions

View file

@ -335,7 +335,7 @@ namespace MinecraftClient.Inventory.ItemPalettes
mappings[319] = ItemType.AcaciaStairs; mappings[319] = ItemType.AcaciaStairs;
mappings[320] = ItemType.DarkOakStairs; mappings[320] = ItemType.DarkOakStairs;
mappings[321] = ItemType.SlimeBlock; mappings[321] = ItemType.SlimeBlock;
mappings[322] = ItemType.GrassPath; mappings[322] = ItemType.DirtPath;
mappings[323] = ItemType.Sunflower; mappings[323] = ItemType.Sunflower;
mappings[324] = ItemType.Lilac; mappings[324] = ItemType.Lilac;
mappings[325] = ItemType.RoseBush; mappings[325] = ItemType.RoseBush;

View file

@ -385,7 +385,7 @@ namespace MinecraftClient.Inventory.ItemPalettes
mappings[369] = ItemType.AcaciaStairs; mappings[369] = ItemType.AcaciaStairs;
mappings[370] = ItemType.DarkOakStairs; mappings[370] = ItemType.DarkOakStairs;
mappings[371] = ItemType.SlimeBlock; mappings[371] = ItemType.SlimeBlock;
mappings[372] = ItemType.GrassPath; mappings[372] = ItemType.DirtPath;
mappings[373] = ItemType.Sunflower; mappings[373] = ItemType.Sunflower;
mappings[374] = ItemType.Lilac; mappings[374] = ItemType.Lilac;
mappings[375] = ItemType.RoseBush; mappings[375] = ItemType.RoseBush;

View file

@ -385,7 +385,7 @@ namespace MinecraftClient.Inventory.ItemPalettes
mappings[369] = ItemType.AcaciaStairs; mappings[369] = ItemType.AcaciaStairs;
mappings[370] = ItemType.DarkOakStairs; mappings[370] = ItemType.DarkOakStairs;
mappings[371] = ItemType.SlimeBlock; mappings[371] = ItemType.SlimeBlock;
mappings[372] = ItemType.GrassPath; mappings[372] = ItemType.DirtPath;
mappings[373] = ItemType.Sunflower; mappings[373] = ItemType.Sunflower;
mappings[374] = ItemType.Lilac; mappings[374] = ItemType.Lilac;
mappings[375] = ItemType.RoseBush; mappings[375] = ItemType.RoseBush;

View file

@ -402,7 +402,7 @@ namespace MinecraftClient.Inventory.ItemPalettes
mappings[390] = ItemType.PackedIce; mappings[390] = ItemType.PackedIce;
mappings[391] = ItemType.AcaciaStairs; mappings[391] = ItemType.AcaciaStairs;
mappings[392] = ItemType.DarkOakStairs; mappings[392] = ItemType.DarkOakStairs;
mappings[393] = ItemType.GrassPath; mappings[393] = ItemType.DirtPath;
mappings[394] = ItemType.Sunflower; mappings[394] = ItemType.Sunflower;
mappings[395] = ItemType.Lilac; mappings[395] = ItemType.Lilac;
mappings[396] = ItemType.RoseBush; mappings[396] = ItemType.RoseBush;

View file

@ -402,7 +402,7 @@ namespace MinecraftClient.Inventory.ItemPalettes
mappings[390] = ItemType.PackedIce; mappings[390] = ItemType.PackedIce;
mappings[391] = ItemType.AcaciaStairs; mappings[391] = ItemType.AcaciaStairs;
mappings[392] = ItemType.DarkOakStairs; mappings[392] = ItemType.DarkOakStairs;
mappings[393] = ItemType.GrassPath; mappings[393] = ItemType.DirtPath;
mappings[394] = ItemType.Sunflower; mappings[394] = ItemType.Sunflower;
mappings[395] = ItemType.Lilac; mappings[395] = ItemType.Lilac;
mappings[396] = ItemType.RoseBush; mappings[396] = ItemType.RoseBush;

File diff suppressed because it is too large Load diff

View file

@ -1,11 +1,10 @@
namespace MinecraftClient.Inventory namespace MinecraftClient.Inventory
{ {
/// <summary> /// <summary>
/// For MC version 1.16.2. /// Generated using the --generator flag on the client
/// Generated using ItemPaletteGenerator.
/// Typical steps to handle new item IDs for newer Minecraft versions: /// Typical steps to handle new item IDs for newer Minecraft versions:
/// 1. Generate registries.json using data reporting on Vanilla Minecraft (https://wiki.vg/Data_Generators) /// 1. Generate registries.json using data reporting on Vanilla Minecraft (https://wiki.vg/Data_Generators) or download it from: https://github.com/PixiGeko/Minecraft-generated-data
/// 2. Generate temporary ItemTypeXXX.cs and ItemPaletteXXX.cs using ItemPaletteGenerator.cs /// 2. Generate temporary ItemTypeXXX.cs and ItemPaletteXXX.cs using the --generator flag on the client
/// 3. Perform a diff with existing versions, add missing entries in ItemType.cs and ItemTypeExtensions.cs /// 3. Perform a diff with existing versions, add missing entries in ItemType.cs and ItemTypeExtensions.cs
/// 4. If existing entity IDs were not randomized by Mojang, simply add missing entries to the latest existing ItemPaletteXXX.cs /// 4. If existing entity IDs were not randomized by Mojang, simply add missing entries to the latest existing ItemPaletteXXX.cs
/// 5. If existing entity IDs were randomized, add a new palette as ItemPaletteXXX.cs into the codebase /// 5. If existing entity IDs were randomized, add a new palette as ItemPaletteXXX.cs into the codebase
@ -17,6 +16,7 @@ namespace MinecraftClient.Inventory
AcaciaBoat, AcaciaBoat,
AcaciaButton, AcaciaButton,
AcaciaChestBoat,
AcaciaDoor, AcaciaDoor,
AcaciaFence, AcaciaFence,
AcaciaFenceGate, AcaciaFenceGate,
@ -32,6 +32,7 @@ namespace MinecraftClient.Inventory
AcaciaWood, AcaciaWood,
ActivatorRail, ActivatorRail,
Air, Air,
AllaySpawnEgg,
Allium, Allium,
AmethystBlock, AmethystBlock,
AmethystCluster, AmethystCluster,
@ -69,6 +70,7 @@ namespace MinecraftClient.Inventory
BigDripleaf, BigDripleaf,
BirchBoat, BirchBoat,
BirchButton, BirchButton,
BirchChestBoat,
BirchDoor, BirchDoor,
BirchFence, BirchFence,
BirchFenceGate, BirchFenceGate,
@ -279,6 +281,7 @@ namespace MinecraftClient.Inventory
Dandelion, Dandelion,
DarkOakBoat, DarkOakBoat,
DarkOakButton, DarkOakButton,
DarkOakChestBoat,
DarkOakDoor, DarkOakDoor,
DarkOakFence, DarkOakFence,
DarkOakFenceGate, DarkOakFenceGate,
@ -349,6 +352,8 @@ namespace MinecraftClient.Inventory
DioriteStairs, DioriteStairs,
DioriteWall, DioriteWall,
Dirt, Dirt,
DirtPath,
DiscFragment5,
Dispenser, Dispenser,
DolphinSpawnEgg, DolphinSpawnEgg,
DonkeySpawnEgg, DonkeySpawnEgg,
@ -360,6 +365,7 @@ namespace MinecraftClient.Inventory
DripstoneBlock, DripstoneBlock,
Dropper, Dropper,
DrownedSpawnEgg, DrownedSpawnEgg,
EchoShard,
Egg, Egg,
ElderGuardianSpawnEgg, ElderGuardianSpawnEgg,
Elytra, Elytra,
@ -408,6 +414,8 @@ namespace MinecraftClient.Inventory
FloweringAzalea, FloweringAzalea,
FloweringAzaleaLeaves, FloweringAzaleaLeaves,
FoxSpawnEgg, FoxSpawnEgg,
FrogSpawnEgg,
Frogspawn,
Furnace, Furnace,
FurnaceMinecart, FurnaceMinecart,
GhastSpawnEgg, GhastSpawnEgg,
@ -425,6 +433,7 @@ namespace MinecraftClient.Inventory
GlowSquidSpawnEgg, GlowSquidSpawnEgg,
Glowstone, Glowstone,
GlowstoneDust, GlowstoneDust,
GoatHorn,
GoatSpawnEgg, GoatSpawnEgg,
GoldBlock, GoldBlock,
GoldIngot, GoldIngot,
@ -448,7 +457,6 @@ namespace MinecraftClient.Inventory
GraniteWall, GraniteWall,
Grass, Grass,
GrassBlock, GrassBlock,
GrassPath,
Gravel, Gravel,
GrayBanner, GrayBanner,
GrayBed, GrayBed,
@ -527,6 +535,7 @@ namespace MinecraftClient.Inventory
Jukebox, Jukebox,
JungleBoat, JungleBoat,
JungleButton, JungleButton,
JungleChestBoat,
JungleDoor, JungleDoor,
JungleFence, JungleFence,
JungleFenceGate, JungleFenceGate,
@ -624,6 +633,23 @@ namespace MinecraftClient.Inventory
MagmaBlock, MagmaBlock,
MagmaCream, MagmaCream,
MagmaCubeSpawnEgg, MagmaCubeSpawnEgg,
MangroveBoat,
MangroveButton,
MangroveChestBoat,
MangroveDoor,
MangroveFence,
MangroveFenceGate,
MangroveLeaves,
MangroveLog,
MangrovePlanks,
MangrovePressurePlate,
MangrovePropagule,
MangroveRoots,
MangroveSign,
MangroveSlab,
MangroveStairs,
MangroveTrapdoor,
MangroveWood,
Map, Map,
MediumAmethystBud, MediumAmethystBud,
Melon, Melon,
@ -643,11 +669,18 @@ namespace MinecraftClient.Inventory
MossyStoneBrickStairs, MossyStoneBrickStairs,
MossyStoneBrickWall, MossyStoneBrickWall,
MossyStoneBricks, MossyStoneBricks,
Mud,
MudBrickSlab,
MudBrickStairs,
MudBrickWall,
MudBricks,
MuddyMangroveRoots,
MuleSpawnEgg, MuleSpawnEgg,
MushroomStem, MushroomStem,
MushroomStew, MushroomStew,
MusicDisc11, MusicDisc11,
MusicDisc13, MusicDisc13,
MusicDisc5,
MusicDiscBlocks, MusicDiscBlocks,
MusicDiscCat, MusicDiscCat,
MusicDiscChirp, MusicDiscChirp,
@ -692,6 +725,7 @@ namespace MinecraftClient.Inventory
NoteBlock, NoteBlock,
OakBoat, OakBoat,
OakButton, OakButton,
OakChestBoat,
OakDoor, OakDoor,
OakFence, OakFence,
OakFenceGate, OakFenceGate,
@ -708,6 +742,7 @@ namespace MinecraftClient.Inventory
Observer, Observer,
Obsidian, Obsidian,
OcelotSpawnEgg, OcelotSpawnEgg,
OchreFroglight,
OrangeBanner, OrangeBanner,
OrangeBed, OrangeBed,
OrangeCandle, OrangeCandle,
@ -728,10 +763,12 @@ namespace MinecraftClient.Inventory
OxidizedCutCopperSlab, OxidizedCutCopperSlab,
OxidizedCutCopperStairs, OxidizedCutCopperStairs,
PackedIce, PackedIce,
PackedMud,
Painting, Painting,
PandaSpawnEgg, PandaSpawnEgg,
Paper, Paper,
ParrotSpawnEgg, ParrotSpawnEgg,
PearlescentFroglight,
Peony, Peony,
PetrifiedOakSlab, PetrifiedOakSlab,
PhantomMembrane, PhantomMembrane,
@ -843,6 +880,7 @@ namespace MinecraftClient.Inventory
RawGoldBlock, RawGoldBlock,
RawIron, RawIron,
RawIronBlock, RawIronBlock,
RecoveryCompass,
RedBanner, RedBanner,
RedBed, RedBed,
RedCandle, RedCandle,
@ -873,6 +911,7 @@ namespace MinecraftClient.Inventory
RedstoneLamp, RedstoneLamp,
RedstoneOre, RedstoneOre,
RedstoneTorch, RedstoneTorch,
ReinforcedDeepslate,
Repeater, Repeater,
RepeatingCommandBlock, RepeatingCommandBlock,
RespawnAnchor, RespawnAnchor,
@ -889,7 +928,11 @@ namespace MinecraftClient.Inventory
SandstoneStairs, SandstoneStairs,
SandstoneWall, SandstoneWall,
Scaffolding, Scaffolding,
Sculk,
SculkCatalyst,
SculkSensor, SculkSensor,
SculkShrieker,
SculkVein,
Scute, Scute,
SeaLantern, SeaLantern,
SeaPickle, SeaPickle,
@ -942,6 +985,7 @@ namespace MinecraftClient.Inventory
SporeBlossom, SporeBlossom,
SpruceBoat, SpruceBoat,
SpruceButton, SpruceButton,
SpruceChestBoat,
SpruceDoor, SpruceDoor,
SpruceFence, SpruceFence,
SpruceFenceGate, SpruceFenceGate,
@ -987,6 +1031,8 @@ namespace MinecraftClient.Inventory
StrippedDarkOakWood, StrippedDarkOakWood,
StrippedJungleLog, StrippedJungleLog,
StrippedJungleWood, StrippedJungleWood,
StrippedMangroveLog,
StrippedMangroveWood,
StrippedOakLog, StrippedOakLog,
StrippedOakWood, StrippedOakWood,
StrippedSpruceLog, StrippedSpruceLog,
@ -1000,6 +1046,8 @@ namespace MinecraftClient.Inventory
Sunflower, Sunflower,
SuspiciousStew, SuspiciousStew,
SweetBerries, SweetBerries,
TadpoleBucket,
TadpoleSpawnEgg,
TallGrass, TallGrass,
Target, Target,
Terracotta, Terracotta,
@ -1024,11 +1072,13 @@ namespace MinecraftClient.Inventory
TurtleHelmet, TurtleHelmet,
TurtleSpawnEgg, TurtleSpawnEgg,
TwistingVines, TwistingVines,
VerdantFroglight,
VexSpawnEgg, VexSpawnEgg,
VillagerSpawnEgg, VillagerSpawnEgg,
VindicatorSpawnEgg, VindicatorSpawnEgg,
Vine, Vine,
WanderingTraderSpawnEgg, WanderingTraderSpawnEgg,
WardenSpawnEgg,
WarpedButton, WarpedButton,
WarpedDoor, WarpedDoor,
WarpedFence, WarpedFence,

View file

@ -760,7 +760,7 @@ namespace MinecraftClient.Mapping.BlockPalettes
materials[8158] = Material.EndStoneBricks; materials[8158] = Material.EndStoneBricks;
for (int i = 8159; i <= 8162; i++) for (int i = 8159; i <= 8162; i++)
materials[i] = Material.Beetroots; materials[i] = Material.Beetroots;
materials[8163] = Material.GrassPath; materials[8163] = Material.DirtPath;
materials[8164] = Material.EndGateway; materials[8164] = Material.EndGateway;
for (int i = 8165; i <= 8176; i++) for (int i = 8165; i <= 8176; i++)
materials[i] = Material.RepeatingCommandBlock; materials[i] = Material.RepeatingCommandBlock;

View file

@ -792,7 +792,7 @@ namespace MinecraftClient.Mapping.BlockPalettes
materials[8682] = Material.EndStoneBricks; materials[8682] = Material.EndStoneBricks;
for (int i = 8683; i <= 8686; i++) for (int i = 8683; i <= 8686; i++)
materials[i] = Material.Beetroots; materials[i] = Material.Beetroots;
materials[8687] = Material.GrassPath; materials[8687] = Material.DirtPath;
materials[8688] = Material.EndGateway; materials[8688] = Material.EndGateway;
for (int i = 8689; i <= 8700; i++) for (int i = 8689; i <= 8700; i++)
materials[i] = Material.RepeatingCommandBlock; materials[i] = Material.RepeatingCommandBlock;

View file

@ -792,7 +792,7 @@ namespace MinecraftClient.Mapping.BlockPalettes
materials[8682] = Material.EndStoneBricks; materials[8682] = Material.EndStoneBricks;
for (int i = 8683; i <= 8686; i++) for (int i = 8683; i <= 8686; i++)
materials[i] = Material.Beetroots; materials[i] = Material.Beetroots;
materials[8687] = Material.GrassPath; materials[8687] = Material.DirtPath;
materials[8688] = Material.EndGateway; materials[8688] = Material.EndGateway;
for (int i = 8689; i <= 8700; i++) for (int i = 8689; i <= 8700; i++)
materials[i] = Material.RepeatingCommandBlock; materials[i] = Material.RepeatingCommandBlock;

View file

@ -800,7 +800,7 @@ namespace MinecraftClient.Mapping.BlockPalettes
materials[9222] = Material.EndStoneBricks; materials[9222] = Material.EndStoneBricks;
for (int i = 9223; i <= 9226; i++) for (int i = 9223; i <= 9226; i++)
materials[i] = Material.Beetroots; materials[i] = Material.Beetroots;
materials[9227] = Material.GrassPath; materials[9227] = Material.DirtPath;
materials[9228] = Material.EndGateway; materials[9228] = Material.EndGateway;
for (int i = 9229; i <= 9240; i++) for (int i = 9229; i <= 9240; i++)
materials[i] = Material.RepeatingCommandBlock; materials[i] = Material.RepeatingCommandBlock;

View file

@ -820,7 +820,7 @@ namespace MinecraftClient.Mapping.BlockPalettes
materials[9468] = Material.EndStoneBricks; materials[9468] = Material.EndStoneBricks;
for (int i = 9469; i <= 9472; i++) for (int i = 9469; i <= 9472; i++)
materials[i] = Material.Beetroots; materials[i] = Material.Beetroots;
materials[9473] = Material.GrassPath; materials[9473] = Material.DirtPath;
materials[9474] = Material.EndGateway; materials[9474] = Material.EndGateway;
for (int i = 9475; i <= 9486; i++) for (int i = 9475; i <= 9486; i++)
materials[i] = Material.RepeatingCommandBlock; materials[i] = Material.RepeatingCommandBlock;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,137 @@
using System;
using System.Collections.Generic;
namespace MinecraftClient.Mapping.EntityPalettes
{
public class EntityPalette119 : EntityPalette
{
private static Dictionary<int, EntityType> mappings = new Dictionary<int, EntityType>();
static EntityPalette119()
{
mappings[0] = EntityType.Allay;
mappings[1] = EntityType.AreaEffectCloud;
mappings[2] = EntityType.ArmorStand;
mappings[3] = EntityType.Arrow;
mappings[4] = EntityType.Axolotl;
mappings[5] = EntityType.Bat;
mappings[6] = EntityType.Bee;
mappings[7] = EntityType.Blaze;
mappings[8] = EntityType.Boat;
mappings[10] = EntityType.Cat;
mappings[11] = EntityType.CaveSpider;
mappings[9] = EntityType.ChestBoat;
mappings[54] = EntityType.ChestMinecart;
mappings[12] = EntityType.Chicken;
mappings[13] = EntityType.Cod;
mappings[55] = EntityType.CommandBlockMinecart;
mappings[14] = EntityType.Cow;
mappings[15] = EntityType.Creeper;
mappings[16] = EntityType.Dolphin;
mappings[17] = EntityType.Donkey;
mappings[18] = EntityType.DragonFireball;
mappings[19] = EntityType.Drowned;
mappings[93] = EntityType.Egg;
mappings[20] = EntityType.ElderGuardian;
mappings[21] = EntityType.EndCrystal;
mappings[22] = EntityType.EnderDragon;
mappings[94] = EntityType.EnderPearl;
mappings[23] = EntityType.Enderman;
mappings[24] = EntityType.Endermite;
mappings[25] = EntityType.Evoker;
mappings[26] = EntityType.EvokerFangs;
mappings[95] = EntityType.ExperienceBottle;
mappings[27] = EntityType.ExperienceOrb;
mappings[28] = EntityType.EyeOfEnder;
mappings[29] = EntityType.FallingBlock;
mappings[46] = EntityType.Fireball;
mappings[30] = EntityType.FireworkRocket;
mappings[117] = EntityType.FishingBobber;
mappings[31] = EntityType.Fox;
mappings[32] = EntityType.Frog;
mappings[56] = EntityType.FurnaceMinecart;
mappings[33] = EntityType.Ghast;
mappings[34] = EntityType.Giant;
mappings[35] = EntityType.GlowItemFrame;
mappings[36] = EntityType.GlowSquid;
mappings[37] = EntityType.Goat;
mappings[38] = EntityType.Guardian;
mappings[39] = EntityType.Hoglin;
mappings[57] = EntityType.HopperMinecart;
mappings[40] = EntityType.Horse;
mappings[41] = EntityType.Husk;
mappings[42] = EntityType.Illusioner;
mappings[43] = EntityType.IronGolem;
mappings[44] = EntityType.Item;
mappings[45] = EntityType.ItemFrame;
mappings[47] = EntityType.LeashKnot;
mappings[48] = EntityType.LightningBolt;
mappings[49] = EntityType.Llama;
mappings[50] = EntityType.LlamaSpit;
mappings[51] = EntityType.MagmaCube;
mappings[52] = EntityType.Marker;
mappings[53] = EntityType.Minecart;
mappings[61] = EntityType.Mooshroom;
mappings[60] = EntityType.Mule;
mappings[62] = EntityType.Ocelot;
mappings[63] = EntityType.Painting;
mappings[64] = EntityType.Panda;
mappings[65] = EntityType.Parrot;
mappings[66] = EntityType.Phantom;
mappings[67] = EntityType.Pig;
mappings[68] = EntityType.Piglin;
mappings[69] = EntityType.PiglinBrute;
mappings[70] = EntityType.Pillager;
mappings[116] = EntityType.Player;
mappings[71] = EntityType.PolarBear;
mappings[96] = EntityType.Potion;
mappings[73] = EntityType.Pufferfish;
mappings[74] = EntityType.Rabbit;
mappings[75] = EntityType.Ravager;
mappings[76] = EntityType.Salmon;
mappings[77] = EntityType.Sheep;
mappings[78] = EntityType.Shulker;
mappings[79] = EntityType.ShulkerBullet;
mappings[80] = EntityType.Silverfish;
mappings[81] = EntityType.Skeleton;
mappings[82] = EntityType.SkeletonHorse;
mappings[83] = EntityType.Slime;
mappings[84] = EntityType.SmallFireball;
mappings[85] = EntityType.SnowGolem;
mappings[86] = EntityType.Snowball;
mappings[58] = EntityType.SpawnerMinecart;
mappings[87] = EntityType.SpectralArrow;
mappings[88] = EntityType.Spider;
mappings[89] = EntityType.Squid;
mappings[90] = EntityType.Stray;
mappings[91] = EntityType.Strider;
mappings[92] = EntityType.Tadpole;
mappings[72] = EntityType.Tnt;
mappings[59] = EntityType.TntMinecart;
mappings[98] = EntityType.TraderLlama;
mappings[97] = EntityType.Trident;
mappings[99] = EntityType.TropicalFish;
mappings[100] = EntityType.Turtle;
mappings[101] = EntityType.Vex;
mappings[102] = EntityType.Villager;
mappings[103] = EntityType.Vindicator;
mappings[104] = EntityType.WanderingTrader;
mappings[105] = EntityType.Warden;
mappings[106] = EntityType.Witch;
mappings[107] = EntityType.Wither;
mappings[108] = EntityType.WitherSkeleton;
mappings[109] = EntityType.WitherSkull;
mappings[110] = EntityType.Wolf;
mappings[111] = EntityType.Zoglin;
mappings[112] = EntityType.Zombie;
mappings[113] = EntityType.ZombieHorse;
mappings[114] = EntityType.ZombieVillager;
mappings[115] = EntityType.ZombifiedPiglin;
}
protected override Dictionary<int, EntityType> GetDict()
{
return mappings;
}
}
}

View file

@ -4,16 +4,17 @@ namespace MinecraftClient.Mapping
/// Represents Minecraft Entity Types /// Represents Minecraft Entity Types
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Generated from registries.json using EntityPaletteGenerator.cs. /// Generated from registries.json using the --generator flag on the client
/// Typical steps to handle new entity IDs for newer Minecraft versions: /// 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) /// 1. Generate registries.json using data reporting on Vanilla Minecraft (https://wiki.vg/Data_Generators) or download it from: https://github.com/PixiGeko/Minecraft-generated-data
/// 2. Generate temporary EntityTypeXXX.cs and EntityPaletteXXX.cs using EntityPaletteGenerator.cs /// 2. Generate temporary EntityTypeXXX.cs and EntityPaletteXXX.cs using the --generator flag on the client
/// 3. Perform a diff with existing versions, add missing entries in EntityType.cs and EntityTypeExtensions.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 /// 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) /// 5. If existing entity IDs were randomized, add a new palette as EntityPaletteXXX.cs into the codebase (worst case)
/// </remarks> /// </remarks>
public enum EntityType public enum EntityType
{ {
Allay,
AreaEffectCloud, AreaEffectCloud,
ArmorStand, ArmorStand,
Arrow, Arrow,
@ -24,6 +25,7 @@ namespace MinecraftClient.Mapping
Boat, Boat,
Cat, Cat,
CaveSpider, CaveSpider,
ChestBoat,
ChestMinecart, ChestMinecart,
Chicken, Chicken,
Cod, Cod,
@ -38,9 +40,9 @@ namespace MinecraftClient.Mapping
ElderGuardian, ElderGuardian,
EndCrystal, EndCrystal,
EnderDragon, EnderDragon,
EnderPearl,
Enderman, Enderman,
Endermite, Endermite,
EnderPearl,
Evoker, Evoker,
EvokerFangs, EvokerFangs,
ExperienceBottle, ExperienceBottle,
@ -51,6 +53,7 @@ namespace MinecraftClient.Mapping
FireworkRocket, FireworkRocket,
FishingBobber, FishingBobber,
Fox, Fox,
Frog,
FurnaceMinecart, FurnaceMinecart,
Ghast, Ghast,
Giant, Giant,
@ -99,14 +102,15 @@ namespace MinecraftClient.Mapping
SkeletonHorse, SkeletonHorse,
Slime, Slime,
SmallFireball, SmallFireball,
Snowball,
SnowGolem, SnowGolem,
Snowball,
SpawnerMinecart, SpawnerMinecart,
SpectralArrow, SpectralArrow,
Spider, Spider,
Squid, Squid,
Stray, Stray,
Strider, Strider,
Tadpole,
Tnt, Tnt,
TntMinecart, TntMinecart,
TraderLlama, TraderLlama,
@ -117,6 +121,7 @@ namespace MinecraftClient.Mapping
Villager, Villager,
Vindicator, Vindicator,
WanderingTrader, WanderingTrader,
Warden,
Witch, Witch,
Wither, Wither,
WitherSkeleton, WitherSkeleton,

View file

@ -4,10 +4,10 @@
/// Represents Minecraft Materials /// Represents Minecraft Materials
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Generated from blocks.json using BlockPaletteGenerator.cs. /// Generated from blocks.json using the --generator flag on the client
/// Typical steps to handle new blocks for newer Minecraft versions: /// Typical steps to handle new blocks for newer Minecraft versions:
/// 1. Generate blocks.json using data reporting on Vanilla Minecraft (https://wiki.vg/Data_Generators) /// 1. Generate blocks.json using data reporting on Vanilla Minecraft (https://wiki.vg/Data_Generators) or download it from: https://github.com/PixiGeko/Minecraft-generated-data
/// 2. Generate temporary MaterialXXX.cs and PaletteXXX.cs using BlockPaletteGenerator.cs /// 2. Generate temporary MaterialXXX.cs and PaletteXXX.cs using the --generator flag on the client
/// 3. Perform a diff with existing versions, add missing entries in Material.cs and MaterialExtensions.cs /// 3. Perform a diff with existing versions, add missing entries in Material.cs and MaterialExtensions.cs
/// 4. If existing state IDs were not randomized by Mojang, simply add missing state entries to Palette113.cs /// 4. If existing state IDs were not randomized by Mojang, simply add missing state entries to Palette113.cs
/// 5. If existing state IDs were randomized, add a new palette as PaletteXXX.cs into the codebase (worst case) /// 5. If existing state IDs were randomized, add a new palette as PaletteXXX.cs into the codebase (worst case)
@ -52,8 +52,8 @@
Basalt, Basalt,
Beacon, Beacon,
Bedrock, Bedrock,
Beehive,
BeeNest, BeeNest,
Beehive,
Beetroots, Beetroots,
Bell, Bell,
BigDripleaf, BigDripleaf,
@ -84,13 +84,13 @@
BlackShulkerBox, BlackShulkerBox,
BlackStainedGlass, BlackStainedGlass,
BlackStainedGlassPane, BlackStainedGlassPane,
BlackTerracotta,
BlackWallBanner,
BlackWool,
Blackstone, Blackstone,
BlackstoneSlab, BlackstoneSlab,
BlackstoneStairs, BlackstoneStairs,
BlackstoneWall, BlackstoneWall,
BlackTerracotta,
BlackWallBanner,
BlackWool,
BlastFurnace, BlastFurnace,
BlueBanner, BlueBanner,
BlueBed, BlueBed,
@ -115,10 +115,10 @@
BrainCoralFan, BrainCoralFan,
BrainCoralWallFan, BrainCoralWallFan,
BrewingStand, BrewingStand,
Bricks,
BrickSlab, BrickSlab,
BrickStairs, BrickStairs,
BrickWall, BrickWall,
Bricks,
BrownBanner, BrownBanner,
BrownBed, BrownBed,
BrownCandle, BrownCandle,
@ -277,10 +277,10 @@
DeadTubeCoralFan, DeadTubeCoralFan,
DeadTubeCoralWallFan, DeadTubeCoralWallFan,
Deepslate, Deepslate,
DeepslateBricks,
DeepslateBrickSlab, DeepslateBrickSlab,
DeepslateBrickStairs, DeepslateBrickStairs,
DeepslateBrickWall, DeepslateBrickWall,
DeepslateBricks,
DeepslateCoalOre, DeepslateCoalOre,
DeepslateCopperOre, DeepslateCopperOre,
DeepslateDiamondOre, DeepslateDiamondOre,
@ -289,10 +289,10 @@
DeepslateIronOre, DeepslateIronOre,
DeepslateLapisOre, DeepslateLapisOre,
DeepslateRedstoneOre, DeepslateRedstoneOre,
DeepslateTiles,
DeepslateTileSlab, DeepslateTileSlab,
DeepslateTileStairs, DeepslateTileStairs,
DeepslateTileWall, DeepslateTileWall,
DeepslateTiles,
DetectorRail, DetectorRail,
DiamondBlock, DiamondBlock,
DiamondOre, DiamondOre,
@ -301,6 +301,7 @@
DioriteStairs, DioriteStairs,
DioriteWall, DioriteWall,
Dirt, Dirt,
DirtPath,
Dispenser, Dispenser,
DragonEgg, DragonEgg,
DragonHead, DragonHead,
@ -311,16 +312,16 @@
EmeraldBlock, EmeraldBlock,
EmeraldOre, EmeraldOre,
EnchantingTable, EnchantingTable,
EnderChest,
EndGateway, EndGateway,
EndPortal, EndPortal,
EndPortalFrame, EndPortalFrame,
EndRod, EndRod,
EndStone, EndStone,
EndStoneBricks,
EndStoneBrickSlab, EndStoneBrickSlab,
EndStoneBrickStairs, EndStoneBrickStairs,
EndStoneBrickWall, EndStoneBrickWall,
EndStoneBricks,
EnderChest,
ExposedCopper, ExposedCopper,
ExposedCutCopper, ExposedCutCopper,
ExposedCutCopperSlab, ExposedCutCopperSlab,
@ -333,9 +334,10 @@
FireCoralFan, FireCoralFan,
FireCoralWallFan, FireCoralWallFan,
FletchingTable, FletchingTable,
FlowerPot,
FloweringAzalea, FloweringAzalea,
FloweringAzaleaLeaves, FloweringAzaleaLeaves,
FlowerPot, Frogspawn,
FrostedIce, FrostedIce,
Furnace, Furnace,
GildedBlackstone, GildedBlackstone,
@ -351,7 +353,6 @@
GraniteWall, GraniteWall,
Grass, Grass,
GrassBlock, GrassBlock,
GrassPath,
Gravel, Gravel,
GrayBanner, GrayBanner,
GrayBed, GrayBed,
@ -464,8 +465,8 @@
LightGrayTerracotta, LightGrayTerracotta,
LightGrayWallBanner, LightGrayWallBanner,
LightGrayWool, LightGrayWool,
LightningRod,
LightWeightedPressurePlate, LightWeightedPressurePlate,
LightningRod,
Lilac, Lilac,
LilyOfTheValley, LilyOfTheValley,
LilyPad, LilyPad,
@ -500,6 +501,22 @@
MagentaWallBanner, MagentaWallBanner,
MagentaWool, MagentaWool,
MagmaBlock, MagmaBlock,
MangroveButton,
MangroveDoor,
MangroveFence,
MangroveFenceGate,
MangroveLeaves,
MangroveLog,
MangrovePlanks,
MangrovePressurePlate,
MangrovePropagule,
MangroveRoots,
MangroveSign,
MangroveSlab,
MangroveStairs,
MangroveTrapdoor,
MangroveWallSign,
MangroveWood,
MediumAmethystBud, MediumAmethystBud,
Melon, Melon,
MelonStem, MelonStem,
@ -509,26 +526,32 @@
MossyCobblestoneSlab, MossyCobblestoneSlab,
MossyCobblestoneStairs, MossyCobblestoneStairs,
MossyCobblestoneWall, MossyCobblestoneWall,
MossyStoneBricks,
MossyStoneBrickSlab, MossyStoneBrickSlab,
MossyStoneBrickStairs, MossyStoneBrickStairs,
MossyStoneBrickWall, MossyStoneBrickWall,
MossyStoneBricks,
MovingPiston, MovingPiston,
Mud,
MudBrickSlab,
MudBrickStairs,
MudBrickWall,
MudBricks,
MuddyMangroveRoots,
MushroomStem, MushroomStem,
Mycelium, Mycelium,
NetherBrickFence, NetherBrickFence,
NetherBricks,
NetherBrickSlab, NetherBrickSlab,
NetherBrickStairs, NetherBrickStairs,
NetherBrickWall, NetherBrickWall,
NetherBricks,
NetherGoldOre, NetherGoldOre,
NetheriteBlock,
NetherPortal, NetherPortal,
NetherQuartzOre, NetherQuartzOre,
Netherrack,
NetherSprouts, NetherSprouts,
NetherWart, NetherWart,
NetherWartBlock, NetherWartBlock,
NetheriteBlock,
Netherrack,
NoteBlock, NoteBlock,
OakButton, OakButton,
OakDoor, OakDoor,
@ -547,6 +570,7 @@
OakWood, OakWood,
Observer, Observer,
Obsidian, Obsidian,
OchreFroglight,
OrangeBanner, OrangeBanner,
OrangeBed, OrangeBed,
OrangeCandle, OrangeCandle,
@ -568,6 +592,8 @@
OxidizedCutCopperSlab, OxidizedCutCopperSlab,
OxidizedCutCopperStairs, OxidizedCutCopperStairs,
PackedIce, PackedIce,
PackedMud,
PearlescentFroglight,
Peony, Peony,
PetrifiedOakSlab, PetrifiedOakSlab,
PinkBanner, PinkBanner,
@ -596,10 +622,10 @@
PolishedAndesiteStairs, PolishedAndesiteStairs,
PolishedBasalt, PolishedBasalt,
PolishedBlackstone, PolishedBlackstone,
PolishedBlackstoneBricks,
PolishedBlackstoneBrickSlab, PolishedBlackstoneBrickSlab,
PolishedBlackstoneBrickStairs, PolishedBlackstoneBrickStairs,
PolishedBlackstoneBrickWall, PolishedBlackstoneBrickWall,
PolishedBlackstoneBricks,
PolishedBlackstoneButton, PolishedBlackstoneButton,
PolishedBlackstonePressurePlate, PolishedBlackstonePressurePlate,
PolishedBlackstoneSlab, PolishedBlackstoneSlab,
@ -636,6 +662,7 @@
PottedFloweringAzaleaBush, PottedFloweringAzaleaBush,
PottedJungleSapling, PottedJungleSapling,
PottedLilyOfTheValley, PottedLilyOfTheValley,
PottedMangrovePropagule,
PottedOakSapling, PottedOakSapling,
PottedOrangeTulip, PottedOrangeTulip,
PottedOxeyeDaisy, PottedOxeyeDaisy,
@ -652,9 +679,9 @@
PowderSnowCauldron, PowderSnowCauldron,
PoweredRail, PoweredRail,
Prismarine, Prismarine,
PrismarineBricks,
PrismarineBrickSlab, PrismarineBrickSlab,
PrismarineBrickStairs, PrismarineBrickStairs,
PrismarineBricks,
PrismarineSlab, PrismarineSlab,
PrismarineStairs, PrismarineStairs,
PrismarineWall, PrismarineWall,
@ -697,10 +724,10 @@
RedGlazedTerracotta, RedGlazedTerracotta,
RedMushroom, RedMushroom,
RedMushroomBlock, RedMushroomBlock,
RedNetherBricks,
RedNetherBrickSlab, RedNetherBrickSlab,
RedNetherBrickStairs, RedNetherBrickStairs,
RedNetherBrickWall, RedNetherBrickWall,
RedNetherBricks,
RedSand, RedSand,
RedSandstone, RedSandstone,
RedSandstoneSlab, RedSandstoneSlab,
@ -709,16 +736,17 @@
RedShulkerBox, RedShulkerBox,
RedStainedGlass, RedStainedGlass,
RedStainedGlassPane, RedStainedGlassPane,
RedTerracotta,
RedTulip,
RedWallBanner,
RedWool,
RedstoneBlock, RedstoneBlock,
RedstoneLamp, RedstoneLamp,
RedstoneOre, RedstoneOre,
RedstoneTorch, RedstoneTorch,
RedstoneWallTorch, RedstoneWallTorch,
RedstoneWire, RedstoneWire,
RedTerracotta, ReinforcedDeepslate,
RedTulip,
RedWallBanner,
RedWool,
Repeater, Repeater,
RepeatingCommandBlock, RepeatingCommandBlock,
RespawnAnchor, RespawnAnchor,
@ -730,10 +758,14 @@
SandstoneStairs, SandstoneStairs,
SandstoneWall, SandstoneWall,
Scaffolding, Scaffolding,
Sculk,
SculkCatalyst,
SculkSensor, SculkSensor,
Seagrass, SculkShrieker,
SculkVein,
SeaLantern, SeaLantern,
SeaPickle, SeaPickle,
Seagrass,
Shroomlight, Shroomlight,
ShulkerBox, ShulkerBox,
SkeletonSkull, SkeletonSkull,
@ -784,15 +816,15 @@
SpruceWood, SpruceWood,
StickyPiston, StickyPiston,
Stone, Stone,
StoneBricks,
StoneBrickSlab, StoneBrickSlab,
StoneBrickStairs, StoneBrickStairs,
StoneBrickWall, StoneBrickWall,
StoneBricks,
StoneButton, StoneButton,
Stonecutter,
StonePressurePlate, StonePressurePlate,
StoneSlab, StoneSlab,
StoneStairs, StoneStairs,
Stonecutter,
StrippedAcaciaLog, StrippedAcaciaLog,
StrippedAcaciaWood, StrippedAcaciaWood,
StrippedBirchLog, StrippedBirchLog,
@ -803,6 +835,8 @@
StrippedDarkOakWood, StrippedDarkOakWood,
StrippedJungleLog, StrippedJungleLog,
StrippedJungleWood, StrippedJungleWood,
StrippedMangroveLog,
StrippedMangroveWood,
StrippedOakLog, StrippedOakLog,
StrippedOakWood, StrippedOakWood,
StrippedSpruceLog, StrippedSpruceLog,
@ -832,6 +866,7 @@
TurtleEgg, TurtleEgg,
TwistingVines, TwistingVines,
TwistingVinesPlant, TwistingVinesPlant,
VerdantFroglight,
Vine, Vine,
VoidAir, VoidAir,
WallTorch, WallTorch,

View file

@ -367,7 +367,7 @@ namespace MinecraftClient.Mapping
Material.Farmland, Material.Farmland,
Material.Grass, Material.Grass,
Material.GrassBlock, Material.GrassBlock,
Material.GrassPath, Material.DirtPath,
Material.Gravel, Material.Gravel,
Material.GrayConcretePowder, Material.GrayConcretePowder,
Material.GreenConcretePowder, Material.GreenConcretePowder,

View file

@ -372,7 +372,7 @@ namespace MinecraftClient.Mapping
case Material.PurpurPillar: case Material.PurpurPillar:
case Material.PurpurStairs: case Material.PurpurStairs:
case Material.EndStoneBricks: case Material.EndStoneBricks:
case Material.GrassPath: case Material.DirtPath:
case Material.RepeatingCommandBlock: case Material.RepeatingCommandBlock:
case Material.ChainCommandBlock: case Material.ChainCommandBlock:
case Material.FrostedIce: case Material.FrostedIce:

View file

@ -403,13 +403,13 @@ namespace MinecraftClient.Protocol.Handlers
Double entityX = ReadNextDouble(cache); Double entityX = ReadNextDouble(cache);
Double entityY = ReadNextDouble(cache); Double entityY = ReadNextDouble(cache);
Double entityZ = ReadNextDouble(cache); Double entityZ = ReadNextDouble(cache);
byte entityYaw = ReadNextByte(cache);
byte entityPitch = ReadNextByte(cache); byte entityPitch = ReadNextByte(cache);
byte entityYaw = ReadNextByte(cache);
int metadata = -1; int metadata = -1;
if (living) if (living)
{ {
if (protocolversion >= Protocol18Handler.MC_1_18_2_Version) if (protocolversion == Protocol18Handler.MC_1_18_2_Version)
entityYaw = ReadNextByte(cache); entityYaw = ReadNextByte(cache);
else else
entityPitch = ReadNextByte(cache); entityPitch = ReadNextByte(cache);
@ -418,15 +418,17 @@ namespace MinecraftClient.Protocol.Handlers
{ {
if (protocolversion >= Protocol18Handler.MC_1_19_Version) if (protocolversion >= Protocol18Handler.MC_1_19_Version)
{ {
metadata = ReadNextVarInt(cache);
entityYaw = ReadNextByte(cache); entityYaw = ReadNextByte(cache);
metadata = ReadNextVarInt(cache);
} }
else else
metadata = ReadNextInt(cache); metadata = ReadNextInt(cache);
} }
short velocityX = ReadNextShort(cache); short velocityX = ReadNextShort(cache);
short velocityY = ReadNextShort(cache); short velocityY = ReadNextShort(cache);
short velocityZ = ReadNextShort(cache); short velocityZ = ReadNextShort(cache);
return new Entity(entityID, entityType, new Location(entityX, entityY, entityZ), entityYaw, entityPitch, metadata); return new Entity(entityID, entityType, new Location(entityX, entityY, entityZ), entityYaw, entityPitch, metadata);
} }

View file

@ -23,7 +23,7 @@ using System.Text.RegularExpressions;
namespace MinecraftClient.Protocol.Handlers namespace MinecraftClient.Protocol.Handlers
{ {
/// <summary> /// <summary>
/// Implementation for Minecraft 1.7.X+ Protocols /// Implementation for Minecraft 1.8.X+ Protocols
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Typical update steps for implementing protocol changes for a new Minecraft version: /// Typical update steps for implementing protocol changes for a new Minecraft version:
@ -62,7 +62,7 @@ namespace MinecraftClient.Protocol.Handlers
private readonly List<string> autocomplete_result = new List<string>(); private readonly List<string> autocomplete_result = new List<string>();
private readonly Dictionary<int, short> window_actions = new Dictionary<int, short>(); private readonly Dictionary<int, short> window_actions = new Dictionary<int, short>();
private bool login_phase = true; private bool login_phase = true;
private int protocolversion; private int protocolVersion;
private int currentDimension; private int currentDimension;
Protocol18Forge pForge; Protocol18Forge pForge;
@ -83,7 +83,7 @@ namespace MinecraftClient.Protocol.Handlers
ChatParser.InitTranslations(); ChatParser.InitTranslations();
this.socketWrapper = new SocketWrapper(Client); this.socketWrapper = new SocketWrapper(Client);
this.dataTypes = new DataTypes(protocolVersion); this.dataTypes = new DataTypes(protocolVersion);
this.protocolversion = protocolVersion; this.protocolVersion = protocolVersion;
this.handler = handler; this.handler = handler;
this.pForge = new Protocol18Forge(forgeInfo, protocolVersion, dataTypes, this, handler); this.pForge = new Protocol18Forge(forgeInfo, protocolVersion, dataTypes, this, handler);
this.pTerrain = new Protocol18Terrain(protocolVersion, dataTypes, handler); this.pTerrain = new Protocol18Terrain(protocolVersion, dataTypes, handler);
@ -91,73 +91,81 @@ namespace MinecraftClient.Protocol.Handlers
this.log = handler.GetLogger(); this.log = handler.GetLogger();
this.randomGen = RandomNumberGenerator.Create(); this.randomGen = RandomNumberGenerator.Create();
if (handler.GetTerrainEnabled() && protocolversion > MC_1_18_2_Version) if (handler.GetTerrainEnabled() && protocolVersion > MC_1_18_2_Version)
{ {
log.Error(Translations.Get("extra.terrainandmovement_disabled")); log.Error(Translations.Get("extra.terrainandmovement_disabled"));
handler.SetTerrainEnabled(false); handler.SetTerrainEnabled(false);
} }
if (handler.GetInventoryEnabled() && (protocolversion < MC_1_10_Version || protocolversion > MC_1_18_2_Version)) if (handler.GetInventoryEnabled() && (protocolVersion < MC_1_10_Version || protocolVersion > MC_1_19_Version))
{ {
log.Error(Translations.Get("extra.inventory_disabled")); log.Error(Translations.Get("extra.inventory_disabled"));
handler.SetInventoryEnabled(false); handler.SetInventoryEnabled(false);
} }
if (handler.GetEntityHandlingEnabled() && (protocolversion < MC_1_10_Version || protocolversion > MC_1_18_2_Version)) if (handler.GetEntityHandlingEnabled() && (protocolVersion < MC_1_10_Version || protocolVersion > MC_1_19_Version))
{ {
log.Error(Translations.Get("extra.entity_disabled")); log.Error(Translations.Get("extra.entity_disabled"));
handler.SetEntityHandlingEnabled(false); handler.SetEntityHandlingEnabled(false);
} }
// Block palette // Block palette
if (protocolversion >= MC_1_13_Version) if (protocolVersion >= MC_1_13_Version)
{ {
if (protocolVersion > MC_1_18_2_Version && handler.GetTerrainEnabled()) if (protocolVersion > MC_1_19_Version && handler.GetTerrainEnabled())
throw new NotImplementedException(Translations.Get("exception.palette.block")); throw new NotImplementedException(Translations.Get("exception.palette.block"));
if (protocolVersion >= MC_1_17_Version)
if (protocolVersion == MC_1_19_Version)
Block.Palette = new Palette119();
else if (protocolVersion >= MC_1_17_Version)
Block.Palette = new Palette117(); Block.Palette = new Palette117();
else if (protocolVersion >= MC_1_16_Version) else if (protocolVersion >= MC_1_16_Version)
if (protocolVersion >= MC_1_16_Version) Block.Palette = new Palette116();
Block.Palette = new Palette116(); else if (protocolVersion >= MC_1_15_Version)
else if (protocolVersion >= MC_1_15_Version) Block.Palette = new Palette115();
Block.Palette = new Palette115(); else if (protocolVersion >= MC_1_14_Version)
else if (protocolVersion >= MC_1_14_Version) Block.Palette = new Palette114();
Block.Palette = new Palette114(); else Block.Palette = new Palette113();
else Block.Palette = new Palette113();
} }
else Block.Palette = new Palette112(); else Block.Palette = new Palette112();
// Entity palette // Entity palette
if (protocolversion >= MC_1_13_Version) if (protocolVersion >= MC_1_13_Version)
{ {
if (protocolversion > MC_1_18_2_Version && handler.GetEntityHandlingEnabled()) if (protocolVersion > MC_1_19_Version && handler.GetEntityHandlingEnabled())
throw new NotImplementedException(Translations.Get("exception.palette.entity")); throw new NotImplementedException(Translations.Get("exception.palette.entity"));
if (protocolversion >= MC_1_17_Version)
if (protocolVersion == MC_1_19_Version)
entityPalette = new EntityPalette119();
else if (protocolVersion >= MC_1_17_Version)
entityPalette = new EntityPalette117(); entityPalette = new EntityPalette117();
else if (protocolversion >= MC_1_16_2_Version) else if (protocolVersion >= MC_1_16_2_Version)
if (protocolversion >= MC_1_16_2_Version) entityPalette = new EntityPalette1162();
entityPalette = new EntityPalette1162(); else if (protocolVersion >= MC_1_16_Version)
else if (protocolversion >= MC_1_16_Version) entityPalette = new EntityPalette1161();
entityPalette = new EntityPalette1161(); else if (protocolVersion >= MC_1_15_Version)
else if (protocolversion >= MC_1_15_Version) entityPalette = new EntityPalette115();
entityPalette = new EntityPalette115(); else if (protocolVersion >= MC_1_14_Version)
else if (protocolVersion >= MC_1_14_Version) entityPalette = new EntityPalette114();
entityPalette = new EntityPalette114(); else entityPalette = new EntityPalette113();
else entityPalette = new EntityPalette113();
} }
else entityPalette = new EntityPalette112(); else entityPalette = new EntityPalette112();
// Item palette // Item palette
if (protocolversion >= MC_1_16_2_Version) if (protocolVersion >= MC_1_16_2_Version)
{ {
if (protocolversion > MC_1_18_2_Version && handler.GetInventoryEnabled()) if (protocolVersion > MC_1_19_Version && handler.GetInventoryEnabled())
throw new NotImplementedException(Translations.Get("exception.palette.item")); throw new NotImplementedException(Translations.Get("exception.palette.item"));
if (protocolversion >= MC_1_18_1_Version)
if (protocolVersion == MC_1_19_Version)
itemPalette = new ItemPalette119();
else if (protocolVersion >= MC_1_18_1_Version)
itemPalette = new ItemPalette118(); itemPalette = new ItemPalette118();
else if (protocolversion >= MC_1_17_Version) else if (protocolVersion >= MC_1_17_Version)
itemPalette = new ItemPalette117(); itemPalette = new ItemPalette117();
else if (protocolversion >= MC_1_16_2_Version) else if (protocolVersion >= MC_1_16_2_Version)
if (protocolversion >= MC_1_16_2_Version) if (protocolVersion >= MC_1_16_2_Version)
itemPalette = new ItemPalette1162(); itemPalette = new ItemPalette1162();
else itemPalette = new ItemPalette1161(); else itemPalette = new ItemPalette1161();
} }
@ -244,7 +252,7 @@ namespace MinecraftClient.Protocol.Handlers
packetData.Enqueue(rawpacket[i]); packetData.Enqueue(rawpacket[i]);
//Handle packet decompression //Handle packet decompression
if (protocolversion >= MC_1_8_Version if (protocolVersion >= MC_1_8_Version
&& compression_treshold > 0) && compression_treshold > 0)
{ {
int sizeUncompressed = dataTypes.ReadNextVarInt(packetData); int sizeUncompressed = dataTypes.ReadNextVarInt(packetData);
@ -282,7 +290,7 @@ namespace MinecraftClient.Protocol.Handlers
switch (packetID) //Packet IDs are different while logging in switch (packetID) //Packet IDs are different while logging in
{ {
case 0x03: case 0x03:
if (protocolversion >= MC_1_8_Version) if (protocolVersion >= MC_1_8_Version)
compression_treshold = dataTypes.ReadNextVarInt(packetData); compression_treshold = dataTypes.ReadNextVarInt(packetData);
break; break;
case 0x04: case 0x04:
@ -309,12 +317,12 @@ namespace MinecraftClient.Protocol.Handlers
int playerEntityID = dataTypes.ReadNextInt(packetData); int playerEntityID = dataTypes.ReadNextInt(packetData);
handler.OnReceivePlayerEntityID(playerEntityID); handler.OnReceivePlayerEntityID(playerEntityID);
if (protocolversion >= MC_1_16_2_Version) if (protocolVersion >= MC_1_16_2_Version)
dataTypes.ReadNextBool(packetData); // Is hardcore - 1.16.2 and above dataTypes.ReadNextBool(packetData); // Is hardcore - 1.16.2 and above
handler.OnGamemodeUpdate(Guid.Empty, dataTypes.ReadNextByte(packetData)); handler.OnGamemodeUpdate(Guid.Empty, dataTypes.ReadNextByte(packetData));
if (protocolversion >= MC_1_16_Version) if (protocolVersion >= MC_1_16_Version)
{ {
dataTypes.ReadNextByte(packetData); // Previous Gamemode - 1.16 and above dataTypes.ReadNextByte(packetData); // Previous Gamemode - 1.16 and above
int worldCount = dataTypes.ReadNextVarInt(packetData); // Dimension Count (World Count) - 1.16 and above int worldCount = dataTypes.ReadNextVarInt(packetData); // Dimension Count (World Count) - 1.16 and above
@ -331,55 +339,55 @@ namespace MinecraftClient.Protocol.Handlers
// String identifier: 1.16 and 1.16.1 // String identifier: 1.16 and 1.16.1
// varInt: [1.9.1 to 1.15.2] // varInt: [1.9.1 to 1.15.2]
// byte: below 1.9.1 // byte: below 1.9.1
if (protocolversion >= MC_1_16_Version) if (protocolVersion >= MC_1_16_Version)
{ {
if (protocolversion >= MC_1_19_Version) if (protocolVersion >= MC_1_19_Version)
{ {
dataTypes.ReadNextString(packetData); // Dimension Type: Identifier dataTypes.ReadNextString(packetData); // Dimension Type: Identifier
currentDimensionType = new Dictionary<string, object>(); currentDimensionType = new Dictionary<string, object>();
} }
else if (protocolversion >= MC_1_16_2_Version) else if (protocolVersion >= MC_1_16_2_Version)
currentDimensionType = dataTypes.ReadNextNbt(packetData); // Dimension Type: NBT Tag Compound currentDimensionType = dataTypes.ReadNextNbt(packetData); // Dimension Type: NBT Tag Compound
else else
dataTypes.ReadNextString(packetData); dataTypes.ReadNextString(packetData);
this.currentDimension = 0; this.currentDimension = 0;
} }
else if (protocolversion >= MC_1_9_1_Version) else if (protocolVersion >= MC_1_9_1_Version)
this.currentDimension = dataTypes.ReadNextInt(packetData); this.currentDimension = dataTypes.ReadNextInt(packetData);
else else
this.currentDimension = (sbyte)dataTypes.ReadNextByte(packetData); this.currentDimension = (sbyte)dataTypes.ReadNextByte(packetData);
if (protocolversion < MC_1_14_Version) if (protocolVersion < MC_1_14_Version)
dataTypes.ReadNextByte(packetData); // Difficulty - 1.13 and below dataTypes.ReadNextByte(packetData); // Difficulty - 1.13 and below
if (protocolversion >= MC_1_16_Version) if (protocolVersion >= MC_1_16_Version)
currentDimensionName = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above currentDimensionName = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above
if (protocolversion >= MC_1_16_2_Version) if (protocolVersion >= MC_1_16_2_Version)
World.SetDimension(currentDimensionName, currentDimensionType); World.SetDimension(currentDimensionName, currentDimensionType);
if (protocolversion >= MC_1_15_Version) if (protocolVersion >= MC_1_15_Version)
dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above
if (protocolversion >= MC_1_16_2_Version) if (protocolVersion >= MC_1_16_2_Version)
dataTypes.ReadNextVarInt(packetData); // Max Players - 1.16.2 and above dataTypes.ReadNextVarInt(packetData); // Max Players - 1.16.2 and above
else else
dataTypes.ReadNextByte(packetData); // Max Players - 1.16.1 and below dataTypes.ReadNextByte(packetData); // Max Players - 1.16.1 and below
if (protocolversion < MC_1_16_Version) if (protocolVersion < MC_1_16_Version)
dataTypes.ReadNextString(packetData); // Level Type - 1.15 and below dataTypes.ReadNextString(packetData); // Level Type - 1.15 and below
if (protocolversion >= MC_1_14_Version) if (protocolVersion >= MC_1_14_Version)
dataTypes.ReadNextVarInt(packetData); // View distance - 1.14 and above dataTypes.ReadNextVarInt(packetData); // View distance - 1.14 and above
if (protocolversion >= MC_1_18_1_Version) if (protocolVersion >= MC_1_18_1_Version)
dataTypes.ReadNextVarInt(packetData); // Simulation Distance - 1.18 and above dataTypes.ReadNextVarInt(packetData); // Simulation Distance - 1.18 and above
if (protocolversion >= MC_1_8_Version) if (protocolVersion >= MC_1_8_Version)
dataTypes.ReadNextBool(packetData); // Reduced debug info - 1.8 and above dataTypes.ReadNextBool(packetData); // Reduced debug info - 1.8 and above
if (protocolversion >= MC_1_15_Version) if (protocolVersion >= MC_1_15_Version)
dataTypes.ReadNextBool(packetData); // Enable respawn screen - 1.15 and above dataTypes.ReadNextBool(packetData); // Enable respawn screen - 1.15 and above
if (protocolversion >= MC_1_16_Version) if (protocolVersion >= MC_1_16_Version)
{ {
dataTypes.ReadNextBool(packetData); // Is Debug - 1.16 and above dataTypes.ReadNextBool(packetData); // Is Debug - 1.16 and above
dataTypes.ReadNextBool(packetData); // Is Flat - 1.16 and above dataTypes.ReadNextBool(packetData); // Is Flat - 1.16 and above
} }
if (protocolversion >= MC_1_19_Version) if (protocolVersion >= MC_1_19_Version)
{ {
bool hasDeathLocation = dataTypes.ReadNextBool(packetData); // Has death location bool hasDeathLocation = dataTypes.ReadNextBool(packetData); // Has death location
if (hasDeathLocation) if (hasDeathLocation)
@ -392,12 +400,12 @@ namespace MinecraftClient.Protocol.Handlers
case PacketTypesIn.ChatMessage: case PacketTypesIn.ChatMessage:
int messageType = 0; int messageType = 0;
if (protocolversion <= MC_1_18_2_Version) // 1.18 and bellow if (protocolVersion <= MC_1_18_2_Version) // 1.18 and bellow
{ {
string message = dataTypes.ReadNextString(packetData); string message = dataTypes.ReadNextString(packetData);
Guid senderUUID; Guid senderUUID;
if (protocolversion >= MC_1_8_Version) if (protocolVersion >= MC_1_8_Version)
{ {
//Hide system messages or xp bar messages? //Hide system messages or xp bar messages?
messageType = dataTypes.ReadNextByte(packetData); messageType = dataTypes.ReadNextByte(packetData);
@ -405,7 +413,7 @@ namespace MinecraftClient.Protocol.Handlers
|| (messageType == 2 && !Settings.DisplayXPBarMessages)) || (messageType == 2 && !Settings.DisplayXPBarMessages))
break; break;
if (protocolversion >= MC_1_16_5_Version) if (protocolVersion >= MC_1_16_5_Version)
senderUUID = dataTypes.ReadNextUUID(packetData); senderUUID = dataTypes.ReadNextUUID(packetData);
else senderUUID = Guid.Empty; else senderUUID = Guid.Empty;
} }
@ -447,14 +455,14 @@ namespace MinecraftClient.Protocol.Handlers
case PacketTypesIn.Respawn: case PacketTypesIn.Respawn:
string? dimensionNameInRespawn = null; string? dimensionNameInRespawn = null;
Dictionary<string, object> dimensionTypeInRespawn = null; Dictionary<string, object> dimensionTypeInRespawn = null;
if (protocolversion >= MC_1_16_Version) if (protocolVersion >= MC_1_16_Version)
{ {
if (protocolversion >= MC_1_19_Version) if (protocolVersion >= MC_1_19_Version)
{ {
dataTypes.ReadNextString(packetData); // Dimension Type: Identifier dataTypes.ReadNextString(packetData); // Dimension Type: Identifier
dimensionTypeInRespawn = new Dictionary<string, object>(); dimensionTypeInRespawn = new Dictionary<string, object>();
} }
else if (protocolversion >= MC_1_16_2_Version) else if (protocolVersion >= MC_1_16_2_Version)
dimensionTypeInRespawn = dataTypes.ReadNextNbt(packetData); // Dimension Type: NBT Tag Compound dimensionTypeInRespawn = dataTypes.ReadNextNbt(packetData); // Dimension Type: NBT Tag Compound
else else
dataTypes.ReadNextString(packetData); dataTypes.ReadNextString(packetData);
@ -465,28 +473,28 @@ namespace MinecraftClient.Protocol.Handlers
// 1.15 and below // 1.15 and below
this.currentDimension = dataTypes.ReadNextInt(packetData); this.currentDimension = dataTypes.ReadNextInt(packetData);
} }
if (protocolversion >= MC_1_16_Version) if (protocolVersion >= MC_1_16_Version)
dimensionNameInRespawn = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above dimensionNameInRespawn = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above
if (protocolversion >= MC_1_16_2_Version) if (protocolVersion >= MC_1_16_2_Version)
World.SetDimension(dimensionNameInRespawn, dimensionTypeInRespawn); World.SetDimension(dimensionNameInRespawn, dimensionTypeInRespawn);
if (protocolversion < MC_1_14_Version) if (protocolVersion < MC_1_14_Version)
dataTypes.ReadNextByte(packetData); // Difficulty - 1.13 and below dataTypes.ReadNextByte(packetData); // Difficulty - 1.13 and below
if (protocolversion >= MC_1_15_Version) if (protocolVersion >= MC_1_15_Version)
dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above
dataTypes.ReadNextByte(packetData); // Gamemode dataTypes.ReadNextByte(packetData); // Gamemode
if (protocolversion >= MC_1_16_Version) if (protocolVersion >= MC_1_16_Version)
dataTypes.ReadNextByte(packetData); // Previous Game mode - 1.16 and above dataTypes.ReadNextByte(packetData); // Previous Game mode - 1.16 and above
if (protocolversion < MC_1_16_Version) if (protocolVersion < MC_1_16_Version)
dataTypes.ReadNextString(packetData); // Level Type - 1.15 and below dataTypes.ReadNextString(packetData); // Level Type - 1.15 and below
if (protocolversion >= MC_1_16_Version) if (protocolVersion >= MC_1_16_Version)
{ {
dataTypes.ReadNextBool(packetData); // Is Debug - 1.16 and above dataTypes.ReadNextBool(packetData); // Is Debug - 1.16 and above
dataTypes.ReadNextBool(packetData); // Is Flat - 1.16 and above dataTypes.ReadNextBool(packetData); // Is Flat - 1.16 and above
dataTypes.ReadNextBool(packetData); // Copy metadata - 1.16 and above dataTypes.ReadNextBool(packetData); // Copy metadata - 1.16 and above
} }
if (protocolversion >= MC_1_19_Version) if (protocolVersion >= MC_1_19_Version)
{ {
bool hasDeathLocation = dataTypes.ReadNextBool(packetData); // Has death location bool hasDeathLocation = dataTypes.ReadNextBool(packetData); // Has death location
if (hasDeathLocation) if (hasDeathLocation)
@ -509,7 +517,7 @@ namespace MinecraftClient.Protocol.Handlers
// entity handling require player pos for distance calculating // entity handling require player pos for distance calculating
if (handler.GetTerrainEnabled() || handler.GetEntityHandlingEnabled()) if (handler.GetTerrainEnabled() || handler.GetEntityHandlingEnabled())
{ {
if (protocolversion >= MC_1_8_Version) if (protocolVersion >= MC_1_8_Version)
{ {
Location location = handler.GetCurrentLocation(); Location location = handler.GetCurrentLocation();
location.X = (locMask & 1 << 0) != 0 ? location.X + x : x; location.X = (locMask & 1 << 0) != 0 ? location.X + x : x;
@ -520,14 +528,14 @@ namespace MinecraftClient.Protocol.Handlers
else handler.UpdateLocation(new Location(x, y, z), yaw, pitch); else handler.UpdateLocation(new Location(x, y, z), yaw, pitch);
} }
if (protocolversion >= MC_1_9_Version) if (protocolVersion >= MC_1_9_Version)
{ {
int teleportID = dataTypes.ReadNextVarInt(packetData); int teleportID = dataTypes.ReadNextVarInt(packetData);
// Teleport confirm packet // Teleport confirm packet
SendPacket(PacketTypesOut.TeleportConfirm, dataTypes.GetVarInt(teleportID)); SendPacket(PacketTypesOut.TeleportConfirm, dataTypes.GetVarInt(teleportID));
} }
if (protocolversion >= MC_1_17_Version) if (protocolVersion >= MC_1_17_Version)
dataTypes.ReadNextBool(packetData); // Dismount Vehicle - 1.17 and above dataTypes.ReadNextBool(packetData); // Dismount Vehicle - 1.17 and above
break; break;
case PacketTypesIn.ChunkData: case PacketTypesIn.ChunkData:
@ -535,16 +543,16 @@ namespace MinecraftClient.Protocol.Handlers
{ {
int chunkX = dataTypes.ReadNextInt(packetData); int chunkX = dataTypes.ReadNextInt(packetData);
int chunkZ = dataTypes.ReadNextInt(packetData); int chunkZ = dataTypes.ReadNextInt(packetData);
if (protocolversion >= MC_1_17_Version) if (protocolVersion >= MC_1_17_Version)
{ {
ulong[]? verticalStripBitmask = null; ulong[]? verticalStripBitmask = null;
if (protocolversion == MC_1_17_Version || protocolversion == MC_1_17_1_Version) if (protocolVersion == MC_1_17_Version || protocolVersion == MC_1_17_1_Version)
verticalStripBitmask = dataTypes.ReadNextULongArray(packetData); // Bit Mask Le:ngth and Primary Bit Mask verticalStripBitmask = dataTypes.ReadNextULongArray(packetData); // Bit Mask Le:ngth and Primary Bit Mask
dataTypes.ReadNextNbt(packetData); // Heightmaps dataTypes.ReadNextNbt(packetData); // Heightmaps
if (protocolversion == MC_1_17_Version || protocolversion == MC_1_17_1_Version) if (protocolVersion == MC_1_17_Version || protocolVersion == MC_1_17_1_Version)
{ {
int biomesLength = dataTypes.ReadNextVarInt(packetData); // Biomes length int biomesLength = dataTypes.ReadNextVarInt(packetData); // Biomes length
for (int i = 0; i < biomesLength; i++) for (int i = 0; i < biomesLength; i++)
@ -566,12 +574,12 @@ namespace MinecraftClient.Protocol.Handlers
else else
{ {
bool chunksContinuous = dataTypes.ReadNextBool(packetData); bool chunksContinuous = dataTypes.ReadNextBool(packetData);
if (protocolversion >= MC_1_16_Version && protocolversion <= MC_1_16_1_Version) if (protocolVersion >= MC_1_16_Version && protocolVersion <= MC_1_16_1_Version)
dataTypes.ReadNextBool(packetData); // Ignore old data - 1.16 to 1.16.1 only dataTypes.ReadNextBool(packetData); // Ignore old data - 1.16 to 1.16.1 only
ushort chunkMask = protocolversion >= MC_1_9_Version ushort chunkMask = protocolVersion >= MC_1_9_Version
? (ushort)dataTypes.ReadNextVarInt(packetData) ? (ushort)dataTypes.ReadNextVarInt(packetData)
: dataTypes.ReadNextUShort(packetData); : dataTypes.ReadNextUShort(packetData);
if (protocolversion < MC_1_8_Version) if (protocolVersion < MC_1_8_Version)
{ {
ushort addBitmap = dataTypes.ReadNextUShort(packetData); ushort addBitmap = dataTypes.ReadNextUShort(packetData);
int compressedDataSize = dataTypes.ReadNextInt(packetData); int compressedDataSize = dataTypes.ReadNextInt(packetData);
@ -584,15 +592,15 @@ namespace MinecraftClient.Protocol.Handlers
} }
else else
{ {
if (protocolversion >= MC_1_14_Version) if (protocolVersion >= MC_1_14_Version)
dataTypes.ReadNextNbt(packetData); // Heightmaps - 1.14 and above dataTypes.ReadNextNbt(packetData); // Heightmaps - 1.14 and above
int biomesLength = 0; int biomesLength = 0;
if (protocolversion >= MC_1_16_2_Version) if (protocolVersion >= MC_1_16_2_Version)
if (chunksContinuous) if (chunksContinuous)
biomesLength = dataTypes.ReadNextVarInt(packetData); // Biomes length - 1.16.2 and above biomesLength = dataTypes.ReadNextVarInt(packetData); // Biomes length - 1.16.2 and above
if (protocolversion >= MC_1_15_Version && chunksContinuous) if (protocolVersion >= MC_1_15_Version && chunksContinuous)
{ {
if (protocolversion >= MC_1_16_2_Version) if (protocolVersion >= MC_1_16_2_Version)
{ {
for (int i = 0; i < biomesLength; i++) for (int i = 0; i < biomesLength; i++)
{ {
@ -615,13 +623,13 @@ namespace MinecraftClient.Protocol.Handlers
case PacketTypesIn.MapData: case PacketTypesIn.MapData:
int mapid = dataTypes.ReadNextVarInt(packetData); int mapid = dataTypes.ReadNextVarInt(packetData);
byte scale = dataTypes.ReadNextByte(packetData); byte scale = dataTypes.ReadNextByte(packetData);
bool trackingposition = protocolversion >= MC_1_17_Version ? false : dataTypes.ReadNextBool(packetData); bool trackingposition = protocolVersion >= MC_1_17_Version ? false : dataTypes.ReadNextBool(packetData);
bool locked = false; bool locked = false;
if (protocolversion >= MC_1_14_Version) if (protocolVersion >= MC_1_14_Version)
{ {
locked = dataTypes.ReadNextBool(packetData); locked = dataTypes.ReadNextBool(packetData);
} }
if (protocolversion >= MC_1_17_Version) if (protocolVersion >= MC_1_17_Version)
{ {
trackingposition = dataTypes.ReadNextBool(packetData); trackingposition = dataTypes.ReadNextBool(packetData);
} }
@ -629,7 +637,7 @@ namespace MinecraftClient.Protocol.Handlers
handler.OnMapData(mapid, scale, trackingposition, locked, iconcount); handler.OnMapData(mapid, scale, trackingposition, locked, iconcount);
break; break;
case PacketTypesIn.TradeList: case PacketTypesIn.TradeList:
if ((protocolversion >= MC_1_14_Version) && (handler.GetInventoryEnabled())) if ((protocolVersion >= MC_1_14_Version) && (handler.GetInventoryEnabled()))
{ {
// MC 1.14 or greater // MC 1.14 or greater
int windowID = dataTypes.ReadNextVarInt(packetData); int windowID = dataTypes.ReadNextVarInt(packetData);
@ -651,7 +659,7 @@ namespace MinecraftClient.Protocol.Handlers
} }
break; break;
case PacketTypesIn.Title: case PacketTypesIn.Title:
if (protocolversion >= MC_1_8_Version) if (protocolVersion >= MC_1_8_Version)
{ {
int action2 = dataTypes.ReadNextVarInt(packetData); int action2 = dataTypes.ReadNextVarInt(packetData);
string titletext = String.Empty; string titletext = String.Empty;
@ -661,7 +669,7 @@ namespace MinecraftClient.Protocol.Handlers
int fadein = -1; int fadein = -1;
int stay = -1; int stay = -1;
int fadeout = -1; int fadeout = -1;
if (protocolversion >= MC_1_10_Version) if (protocolVersion >= MC_1_10_Version)
{ {
if (action2 == 0) if (action2 == 0)
{ {
@ -710,7 +718,7 @@ namespace MinecraftClient.Protocol.Handlers
case PacketTypesIn.MultiBlockChange: case PacketTypesIn.MultiBlockChange:
if (handler.GetTerrainEnabled()) if (handler.GetTerrainEnabled())
{ {
if (protocolversion >= MC_1_16_2_Version) if (protocolVersion >= MC_1_16_2_Version)
{ {
long chunkSection = dataTypes.ReadNextLong(packetData); long chunkSection = dataTypes.ReadNextLong(packetData);
int sectionX = (int)(chunkSection >> 42); int sectionX = (int)(chunkSection >> 42);
@ -738,7 +746,7 @@ namespace MinecraftClient.Protocol.Handlers
{ {
int chunkX = dataTypes.ReadNextInt(packetData); int chunkX = dataTypes.ReadNextInt(packetData);
int chunkZ = dataTypes.ReadNextInt(packetData); int chunkZ = dataTypes.ReadNextInt(packetData);
int recordCount = protocolversion < MC_1_8_Version int recordCount = protocolVersion < MC_1_8_Version
? (int)dataTypes.ReadNextShort(packetData) ? (int)dataTypes.ReadNextShort(packetData)
: dataTypes.ReadNextVarInt(packetData); : dataTypes.ReadNextVarInt(packetData);
@ -748,7 +756,7 @@ namespace MinecraftClient.Protocol.Handlers
ushort blockIdMeta; ushort blockIdMeta;
int blockY; int blockY;
if (protocolversion < MC_1_8_Version) if (protocolVersion < MC_1_8_Version)
{ {
blockIdMeta = dataTypes.ReadNextUShort(packetData); blockIdMeta = dataTypes.ReadNextUShort(packetData);
blockY = (ushort)dataTypes.ReadNextByte(packetData); blockY = (ushort)dataTypes.ReadNextByte(packetData);
@ -787,7 +795,7 @@ namespace MinecraftClient.Protocol.Handlers
case PacketTypesIn.BlockChange: case PacketTypesIn.BlockChange:
if (handler.GetTerrainEnabled()) if (handler.GetTerrainEnabled())
{ {
if (protocolversion < MC_1_8_Version) if (protocolVersion < MC_1_8_Version)
{ {
int blockX = dataTypes.ReadNextInt(packetData); int blockX = dataTypes.ReadNextInt(packetData);
int blockY = dataTypes.ReadNextByte(packetData); int blockY = dataTypes.ReadNextByte(packetData);
@ -798,7 +806,12 @@ namespace MinecraftClient.Protocol.Handlers
} }
else else
{ {
handler.GetWorld().SetBlock(dataTypes.ReadNextLocation(packetData), new Block((ushort)dataTypes.ReadNextVarInt(packetData))); if (protocolVersion < MC_1_19_Version)
handler.GetWorld().SetBlock(dataTypes.ReadNextLocation(packetData), new Block((ushort)dataTypes.ReadNextVarInt(packetData)));
else
{
// 1.19 disabled due to crashing
}
} }
} }
break; break;
@ -823,14 +836,14 @@ namespace MinecraftClient.Protocol.Handlers
break; break;
case PacketTypesIn.MapChunkBulk: case PacketTypesIn.MapChunkBulk:
if (protocolversion < MC_1_9_Version && handler.GetTerrainEnabled()) if (protocolVersion < MC_1_9_Version && handler.GetTerrainEnabled())
{ {
int chunkCount; int chunkCount;
bool hasSkyLight; bool hasSkyLight;
Queue<byte> chunkData = packetData; Queue<byte> chunkData = packetData;
//Read global fields //Read global fields
if (protocolversion < MC_1_8_Version) if (protocolVersion < MC_1_8_Version)
{ {
chunkCount = dataTypes.ReadNextShort(packetData); chunkCount = dataTypes.ReadNextShort(packetData);
int compressedDataSize = dataTypes.ReadNextInt(packetData); int compressedDataSize = dataTypes.ReadNextInt(packetData);
@ -855,7 +868,7 @@ namespace MinecraftClient.Protocol.Handlers
chunkXs[chunkColumnNo] = dataTypes.ReadNextInt(packetData); chunkXs[chunkColumnNo] = dataTypes.ReadNextInt(packetData);
chunkZs[chunkColumnNo] = dataTypes.ReadNextInt(packetData); chunkZs[chunkColumnNo] = dataTypes.ReadNextInt(packetData);
chunkMasks[chunkColumnNo] = dataTypes.ReadNextUShort(packetData); chunkMasks[chunkColumnNo] = dataTypes.ReadNextUShort(packetData);
addBitmaps[chunkColumnNo] = protocolversion < MC_1_8_Version addBitmaps[chunkColumnNo] = protocolVersion < MC_1_8_Version
? dataTypes.ReadNextUShort(packetData) ? dataTypes.ReadNextUShort(packetData)
: (ushort)0; : (ushort)0;
} }
@ -866,7 +879,7 @@ namespace MinecraftClient.Protocol.Handlers
} }
break; break;
case PacketTypesIn.UnloadChunk: case PacketTypesIn.UnloadChunk:
if (protocolversion >= MC_1_9_Version && handler.GetTerrainEnabled()) if (protocolVersion >= MC_1_9_Version && handler.GetTerrainEnabled())
{ {
int chunkX = dataTypes.ReadNextInt(packetData); int chunkX = dataTypes.ReadNextInt(packetData);
int chunkZ = dataTypes.ReadNextInt(packetData); int chunkZ = dataTypes.ReadNextInt(packetData);
@ -881,7 +894,7 @@ namespace MinecraftClient.Protocol.Handlers
} }
break; break;
case PacketTypesIn.PlayerInfo: case PacketTypesIn.PlayerInfo:
if (protocolversion >= MC_1_8_Version) if (protocolVersion >= MC_1_8_Version)
{ {
int action = dataTypes.ReadNextVarInt(packetData); // Action Name int action = dataTypes.ReadNextVarInt(packetData); // Action Name
int numberOfPlayers = dataTypes.ReadNextVarInt(packetData); // Number Of Players int numberOfPlayers = dataTypes.ReadNextVarInt(packetData); // Number Of Players
@ -918,7 +931,7 @@ namespace MinecraftClient.Protocol.Handlers
// 1.19 Additions // 1.19 Additions
long? keyExpiration = null; long? keyExpiration = null;
byte[]? publicKey = null, signature = null; byte[]? publicKey = null, signature = null;
if (protocolversion >= MC_1_19_Version) if (protocolVersion >= MC_1_19_Version)
{ {
if (dataTypes.ReadNextBool(packetData)) // Has Sig Data (if true, red the following fields) if (dataTypes.ReadNextBool(packetData)) // Has Sig Data (if true, red the following fields)
{ {
@ -968,7 +981,7 @@ namespace MinecraftClient.Protocol.Handlers
} }
break; break;
case PacketTypesIn.TabComplete: case PacketTypesIn.TabComplete:
if (protocolversion >= MC_1_13_Version) if (protocolVersion >= MC_1_13_Version)
{ {
autocomplete_transaction_id = dataTypes.ReadNextVarInt(packetData); autocomplete_transaction_id = dataTypes.ReadNextVarInt(packetData);
dataTypes.ReadNextVarInt(packetData); // Start of text to replace dataTypes.ReadNextVarInt(packetData); // Start of text to replace
@ -981,7 +994,7 @@ namespace MinecraftClient.Protocol.Handlers
for (int i = 0; i < autocomplete_count; i++) for (int i = 0; i < autocomplete_count; i++)
{ {
autocomplete_result.Add(dataTypes.ReadNextString(packetData)); autocomplete_result.Add(dataTypes.ReadNextString(packetData));
if (protocolversion >= MC_1_13_Version) if (protocolVersion >= MC_1_13_Version)
{ {
// Skip optional tooltip for each tab-complete result // Skip optional tooltip for each tab-complete result
if (dataTypes.ReadNextBool(packetData)) if (dataTypes.ReadNextBool(packetData))
@ -994,7 +1007,7 @@ namespace MinecraftClient.Protocol.Handlers
case PacketTypesIn.PluginMessage: case PacketTypesIn.PluginMessage:
String channel = dataTypes.ReadNextString(packetData); String channel = dataTypes.ReadNextString(packetData);
// Length is unneeded as the whole remaining packetData is the entire payload of the packet. // Length is unneeded as the whole remaining packetData is the entire payload of the packet.
if (protocolversion < MC_1_8_Version) if (protocolVersion < MC_1_8_Version)
pForge.ReadNextVarShort(packetData); pForge.ReadNextVarShort(packetData);
handler.OnPluginChannelMessage(channel, packetData.ToArray()); handler.OnPluginChannelMessage(channel, packetData.ToArray());
return pForge.HandlePluginMessage(channel, packetData, ref currentDimension); return pForge.HandlePluginMessage(channel, packetData, ref currentDimension);
@ -1002,13 +1015,13 @@ namespace MinecraftClient.Protocol.Handlers
handler.OnConnectionLost(ChatBot.DisconnectReason.InGameKick, ChatParser.ParseText(dataTypes.ReadNextString(packetData))); handler.OnConnectionLost(ChatBot.DisconnectReason.InGameKick, ChatParser.ParseText(dataTypes.ReadNextString(packetData)));
return false; return false;
case PacketTypesIn.SetCompression: case PacketTypesIn.SetCompression:
if (protocolversion >= MC_1_8_Version && protocolversion < MC_1_9_Version) if (protocolVersion >= MC_1_8_Version && protocolVersion < MC_1_9_Version)
compression_treshold = dataTypes.ReadNextVarInt(packetData); compression_treshold = dataTypes.ReadNextVarInt(packetData);
break; break;
case PacketTypesIn.OpenWindow: case PacketTypesIn.OpenWindow:
if (handler.GetInventoryEnabled()) if (handler.GetInventoryEnabled())
{ {
if (protocolversion < MC_1_14_Version) if (protocolVersion < MC_1_14_Version)
{ {
// MC 1.13 or lower // MC 1.13 or lower
byte windowID = dataTypes.ReadNextByte(packetData); byte windowID = dataTypes.ReadNextByte(packetData);
@ -1045,7 +1058,7 @@ namespace MinecraftClient.Protocol.Handlers
int stateId = -1; int stateId = -1;
int elements = 0; int elements = 0;
if (protocolversion >= MC_1_17_1_Version) if (protocolVersion >= MC_1_17_1_Version)
{ {
// State ID and Elements as VarInt - 1.17.1 and above // State ID and Elements as VarInt - 1.17.1 and above
stateId = dataTypes.ReadNextVarInt(packetData); stateId = dataTypes.ReadNextVarInt(packetData);
@ -1065,7 +1078,7 @@ namespace MinecraftClient.Protocol.Handlers
inventorySlots[slotId] = item; inventorySlots[slotId] = item;
} }
if (protocolversion >= MC_1_17_1_Version) // Carried Item - 1.17.1 and above if (protocolVersion >= MC_1_17_1_Version) // Carried Item - 1.17.1 and above
dataTypes.ReadNextItemSlot(packetData, itemPalette); dataTypes.ReadNextItemSlot(packetData, itemPalette);
handler.OnWindowItems(windowId, inventorySlots, stateId); handler.OnWindowItems(windowId, inventorySlots, stateId);
@ -1076,7 +1089,7 @@ namespace MinecraftClient.Protocol.Handlers
{ {
byte windowID = dataTypes.ReadNextByte(packetData); byte windowID = dataTypes.ReadNextByte(packetData);
int stateId = -1; int stateId = -1;
if (protocolversion >= MC_1_17_1_Version) if (protocolVersion >= MC_1_17_1_Version)
stateId = dataTypes.ReadNextVarInt(packetData); // State ID - 1.17.1 and above stateId = dataTypes.ReadNextVarInt(packetData); // State ID - 1.17.1 and above
short slotID = dataTypes.ReadNextShort(packetData); short slotID = dataTypes.ReadNextShort(packetData);
Item item = dataTypes.ReadNextItemSlot(packetData, itemPalette); Item item = dataTypes.ReadNextItemSlot(packetData, itemPalette);
@ -1099,7 +1112,7 @@ namespace MinecraftClient.Protocol.Handlers
string url = dataTypes.ReadNextString(packetData); string url = dataTypes.ReadNextString(packetData);
string hash = dataTypes.ReadNextString(packetData); string hash = dataTypes.ReadNextString(packetData);
bool forced = true; // Assume forced for MC 1.16 and below bool forced = true; // Assume forced for MC 1.16 and below
if (protocolversion >= MC_1_17_Version) if (protocolVersion >= MC_1_17_Version)
{ {
forced = dataTypes.ReadNextBool(packetData); forced = dataTypes.ReadNextBool(packetData);
string forcedMessage = ChatParser.ParseText(dataTypes.ReadNextString(packetData)); string forcedMessage = ChatParser.ParseText(dataTypes.ReadNextString(packetData));
@ -1111,7 +1124,7 @@ namespace MinecraftClient.Protocol.Handlers
break; break;
//Send back "accepted" and "successfully loaded" responses for plugins or server config making use of resource pack mandatory //Send back "accepted" and "successfully loaded" responses for plugins or server config making use of resource pack mandatory
byte[] responseHeader = new byte[0]; byte[] responseHeader = new byte[0];
if (protocolversion < MC_1_10_Version) //MC 1.10 does not include resource pack hash in responses if (protocolVersion < MC_1_10_Version) //MC 1.10 does not include resource pack hash in responses
responseHeader = dataTypes.ConcatBytes(dataTypes.GetVarInt(hash.Length), Encoding.UTF8.GetBytes(hash)); responseHeader = dataTypes.ConcatBytes(dataTypes.GetVarInt(hash.Length), Encoding.UTF8.GetBytes(hash));
SendPacket(PacketTypesOut.ResourcePackStatus, dataTypes.ConcatBytes(responseHeader, dataTypes.GetVarInt(3))); //Accepted pack SendPacket(PacketTypesOut.ResourcePackStatus, dataTypes.ConcatBytes(responseHeader, dataTypes.GetVarInt(3))); //Accepted pack
SendPacket(PacketTypesOut.ResourcePackStatus, dataTypes.ConcatBytes(responseHeader, dataTypes.GetVarInt(0))); //Successfully loaded SendPacket(PacketTypesOut.ResourcePackStatus, dataTypes.ConcatBytes(responseHeader, dataTypes.GetVarInt(0))); //Successfully loaded
@ -1127,7 +1140,7 @@ namespace MinecraftClient.Protocol.Handlers
if (handler.GetEntityHandlingEnabled()) if (handler.GetEntityHandlingEnabled())
{ {
int entityid = dataTypes.ReadNextVarInt(packetData); int entityid = dataTypes.ReadNextVarInt(packetData);
if (protocolversion >= MC_1_16_Version) if (protocolVersion >= MC_1_16_Version)
{ {
bool hasNext; bool hasNext;
do do
@ -1188,7 +1201,7 @@ namespace MinecraftClient.Protocol.Handlers
bool hasFactorData = false; bool hasFactorData = false;
Dictionary<string, object>? factorCodec = null; Dictionary<string, object>? factorCodec = null;
if (protocolversion >= MC_1_19_Version) if (protocolVersion >= MC_1_19_Version)
{ {
hasFactorData = dataTypes.ReadNextBool(packetData); hasFactorData = dataTypes.ReadNextBool(packetData);
factorCodec = dataTypes.ReadNextNbt(packetData); factorCodec = dataTypes.ReadNextNbt(packetData);
@ -1202,7 +1215,7 @@ namespace MinecraftClient.Protocol.Handlers
if (handler.GetEntityHandlingEnabled()) if (handler.GetEntityHandlingEnabled())
{ {
int entityCount = 1; // 1.17.0 has only one entity per packet int entityCount = 1; // 1.17.0 has only one entity per packet
if (protocolversion != MC_1_17_Version) if (protocolVersion != MC_1_17_Version)
entityCount = dataTypes.ReadNextVarInt(packetData); // All other versions have a "count" field entityCount = dataTypes.ReadNextVarInt(packetData); // All other versions have a "count" field
int[] entityList = new int[entityCount]; int[] entityList = new int[entityCount];
for (int i = 0; i < entityCount; i++) for (int i = 0; i < entityCount; i++)
@ -1246,7 +1259,7 @@ namespace MinecraftClient.Protocol.Handlers
if (handler.GetEntityHandlingEnabled()) if (handler.GetEntityHandlingEnabled())
{ {
int EntityID = dataTypes.ReadNextVarInt(packetData); int EntityID = dataTypes.ReadNextVarInt(packetData);
int NumberOfProperties = protocolversion >= MC_1_17_Version ? dataTypes.ReadNextVarInt(packetData) : dataTypes.ReadNextInt(packetData); int NumberOfProperties = protocolVersion >= MC_1_17_Version ? dataTypes.ReadNextVarInt(packetData) : dataTypes.ReadNextInt(packetData);
Dictionary<string, Double> keys = new Dictionary<string, Double>(); Dictionary<string, Double> keys = new Dictionary<string, Double>();
for (int i = 0; i < NumberOfProperties; i++) for (int i = 0; i < NumberOfProperties; i++)
{ {
@ -1285,11 +1298,11 @@ namespace MinecraftClient.Protocol.Handlers
// See https://wiki.vg/Entity_metadata#Living_Entity // See https://wiki.vg/Entity_metadata#Living_Entity
int healthField = 7; // From 1.10 to 1.13.2 int healthField = 7; // From 1.10 to 1.13.2
if (protocolversion >= MC_1_14_Version) if (protocolVersion >= MC_1_14_Version)
healthField = 8; // 1.14 and above healthField = 8; // 1.14 and above
if (protocolversion >= MC_1_17_Version) if (protocolVersion >= MC_1_17_Version)
healthField = 9; // 1.17 and above healthField = 9; // 1.17 and above
if (protocolversion > MC_1_18_2_Version) if (protocolVersion > MC_1_19_Version)
throw new NotImplementedException(Translations.Get("exception.palette.healthfield")); throw new NotImplementedException(Translations.Get("exception.palette.healthfield"));
if (metadata.ContainsKey(healthField) && metadata[healthField] != null && metadata[healthField].GetType() == typeof(float)) if (metadata.ContainsKey(healthField) && metadata[healthField] != null && metadata[healthField].GetType() == typeof(float))
@ -1333,7 +1346,7 @@ namespace MinecraftClient.Protocol.Handlers
case PacketTypesIn.UpdateHealth: case PacketTypesIn.UpdateHealth:
float health = dataTypes.ReadNextFloat(packetData); float health = dataTypes.ReadNextFloat(packetData);
int food; int food;
if (protocolversion >= MC_1_8_Version) if (protocolVersion >= MC_1_8_Version)
food = dataTypes.ReadNextVarInt(packetData); food = dataTypes.ReadNextVarInt(packetData);
else else
food = dataTypes.ReadNextShort(packetData); food = dataTypes.ReadNextShort(packetData);
@ -1348,12 +1361,12 @@ namespace MinecraftClient.Protocol.Handlers
break; break;
case PacketTypesIn.Explosion: case PacketTypesIn.Explosion:
Location explosionLocation; Location explosionLocation;
if (protocolversion >= MC_1_19_Version) if (protocolVersion >= MC_1_19_Version)
explosionLocation = new(dataTypes.ReadNextDouble(packetData), dataTypes.ReadNextDouble(packetData), dataTypes.ReadNextDouble(packetData)); explosionLocation = new(dataTypes.ReadNextDouble(packetData), dataTypes.ReadNextDouble(packetData), dataTypes.ReadNextDouble(packetData));
else else
explosionLocation = new(dataTypes.ReadNextFloat(packetData), dataTypes.ReadNextFloat(packetData), dataTypes.ReadNextFloat(packetData)); explosionLocation = new(dataTypes.ReadNextFloat(packetData), dataTypes.ReadNextFloat(packetData), dataTypes.ReadNextFloat(packetData));
float explosionStrength = dataTypes.ReadNextFloat(packetData); float explosionStrength = dataTypes.ReadNextFloat(packetData);
int explosionBlockCount = protocolversion >= MC_1_17_Version int explosionBlockCount = protocolVersion >= MC_1_17_Version
? dataTypes.ReadNextVarInt(packetData) ? dataTypes.ReadNextVarInt(packetData)
: dataTypes.ReadNextInt(packetData); : dataTypes.ReadNextInt(packetData);
// Ignoring additional fields (records, pushback) // Ignoring additional fields (records, pushback)
@ -1377,12 +1390,12 @@ namespace MinecraftClient.Protocol.Handlers
break; break;
case PacketTypesIn.UpdateScore: case PacketTypesIn.UpdateScore:
string entityname = dataTypes.ReadNextString(packetData); string entityname = dataTypes.ReadNextString(packetData);
int action3 = protocolversion >= MC_1_18_2_Version int action3 = protocolVersion >= MC_1_18_2_Version
? dataTypes.ReadNextVarInt(packetData) ? dataTypes.ReadNextVarInt(packetData)
: dataTypes.ReadNextByte(packetData); : dataTypes.ReadNextByte(packetData);
string objectivename2 = string.Empty; string objectivename2 = string.Empty;
int value = -1; int value = -1;
if (action3 != 1 || protocolversion >= MC_1_8_Version) if (action3 != 1 || protocolVersion >= MC_1_8_Version)
objectivename2 = dataTypes.ReadNextString(packetData); objectivename2 = dataTypes.ReadNextString(packetData);
if (action3 != 1) if (action3 != 1)
value = dataTypes.ReadNextVarInt(packetData); value = dataTypes.ReadNextVarInt(packetData);
@ -1421,7 +1434,7 @@ namespace MinecraftClient.Protocol.Handlers
Translations.Get("exception.packet_process", Translations.Get("exception.packet_process",
packetPalette.GetIncommingTypeById(packetID), packetPalette.GetIncommingTypeById(packetID),
packetID, packetID,
protocolversion, protocolVersion,
login_phase, login_phase,
innerException.GetType()), innerException.GetType()),
innerException); innerException);
@ -1515,7 +1528,7 @@ namespace MinecraftClient.Protocol.Handlers
/// <returns>True if login successful</returns> /// <returns>True if login successful</returns>
public bool Login(PlayerKeyPair? playerKeyPair) public bool Login(PlayerKeyPair? playerKeyPair)
{ {
byte[] protocol_version = dataTypes.GetVarInt(protocolversion); byte[] protocol_version = dataTypes.GetVarInt(protocolVersion);
string server_address = pForge.GetServerAddress(handler.GetServerHost()); string server_address = pForge.GetServerAddress(handler.GetServerHost());
byte[] server_port = dataTypes.GetUShort((ushort)handler.GetServerPort()); byte[] server_port = dataTypes.GetUShort((ushort)handler.GetServerPort());
byte[] next_state = dataTypes.GetVarInt(2); byte[] next_state = dataTypes.GetVarInt(2);
@ -1524,7 +1537,7 @@ namespace MinecraftClient.Protocol.Handlers
List<byte> fullLoginPacket = new List<byte>(); List<byte> fullLoginPacket = new List<byte>();
fullLoginPacket.AddRange(dataTypes.GetString(handler.GetUsername())); // Username fullLoginPacket.AddRange(dataTypes.GetString(handler.GetUsername())); // Username
if (protocolversion >= MC_1_19_Version) if (protocolVersion >= MC_1_19_Version)
{ {
if (playerKeyPair == null) if (playerKeyPair == null)
fullLoginPacket.AddRange(dataTypes.GetBool(false)); // Has Sig Data fullLoginPacket.AddRange(dataTypes.GetBool(false)); // Has Sig Data
@ -1598,7 +1611,7 @@ namespace MinecraftClient.Protocol.Handlers
// Encryption Response packet // Encryption Response packet
List<byte> encryptionResponse = new(); List<byte> encryptionResponse = new();
encryptionResponse.AddRange(dataTypes.GetArray(RSAService.Encrypt(secretKey, false))); // Shared Secret encryptionResponse.AddRange(dataTypes.GetArray(RSAService.Encrypt(secretKey, false))); // Shared Secret
if (protocolversion >= Protocol18Handler.MC_1_19_Version) if (protocolVersion >= Protocol18Handler.MC_1_19_Version)
{ {
if (playerKeyPair == null) if (playerKeyPair == null)
{ {
@ -1646,7 +1659,7 @@ namespace MinecraftClient.Protocol.Handlers
Guid uuidReceived = dataTypes.ReadNextUUID(packetData); Guid uuidReceived = dataTypes.ReadNextUUID(packetData);
string userName = dataTypes.ReadNextString(packetData); string userName = dataTypes.ReadNextString(packetData);
Tuple<string, string, string>[]? playerProperty = null; Tuple<string, string, string>[]? playerProperty = null;
if (protocolversion >= Protocol18Handler.MC_1_19_Version) if (protocolVersion >= Protocol18Handler.MC_1_19_Version)
{ {
int count = dataTypes.ReadNextVarInt(packetData); // Number Of Properties int count = dataTypes.ReadNextVarInt(packetData); // Number Of Properties
playerProperty = new Tuple<string, string, string>[count]; playerProperty = new Tuple<string, string, string>[count];
@ -1701,9 +1714,9 @@ namespace MinecraftClient.Protocol.Handlers
byte[] tabcomplete_packet = new byte[] { }; byte[] tabcomplete_packet = new byte[] { };
if (protocolversion >= MC_1_8_Version) if (protocolVersion >= MC_1_8_Version)
{ {
if (protocolversion >= MC_1_13_Version) if (protocolVersion >= MC_1_13_Version)
{ {
tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, transaction_id); tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, transaction_id);
tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, dataTypes.GetString(BehindCursor)); tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, dataTypes.GetString(BehindCursor));
@ -1712,7 +1725,7 @@ namespace MinecraftClient.Protocol.Handlers
{ {
tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, dataTypes.GetString(BehindCursor)); tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, dataTypes.GetString(BehindCursor));
if (protocolversion >= MC_1_9_Version) if (protocolVersion >= MC_1_9_Version)
{ {
tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, assume_command); tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, assume_command);
} }
@ -1745,7 +1758,7 @@ namespace MinecraftClient.Protocol.Handlers
/// Ping a Minecraft server to get information about the server /// Ping a Minecraft server to get information about the server
/// </summary> /// </summary>
/// <returns>True if ping was successful</returns> /// <returns>True if ping was successful</returns>
public static bool doPing(string host, int port, ref int protocolversion, ref ForgeInfo? forgeInfo) public static bool doPing(string host, int port, ref int protocolVersion, ref ForgeInfo? forgeInfo)
{ {
string version = ""; string version = "";
TcpClient tcp = ProxyHandler.newTcpClient(host, port); TcpClient tcp = ProxyHandler.newTcpClient(host, port);
@ -1797,12 +1810,12 @@ namespace MinecraftClient.Protocol.Handlers
//Retrieve protocol version number for handling this server //Retrieve protocol version number for handling this server
if (versionData.Properties.ContainsKey("protocol")) if (versionData.Properties.ContainsKey("protocol"))
protocolversion = int.Parse(versionData.Properties["protocol"].StringValue); protocolVersion = int.Parse(versionData.Properties["protocol"].StringValue);
// Check for forge on the server. // Check for forge on the server.
Protocol18Forge.ServerInfoCheckForge(jsonData, ref forgeInfo); Protocol18Forge.ServerInfoCheckForge(jsonData, ref forgeInfo);
ConsoleIO.WriteLineFormatted(Translations.Get("mcc.server_protocol", version, protocolversion + (forgeInfo != null ? Translations.Get("mcc.with_forge") : ""))); ConsoleIO.WriteLineFormatted(Translations.Get("mcc.server_protocol", version, protocolVersion + (forgeInfo != null ? Translations.Get("mcc.with_forge") : "")));
return true; return true;
} }
@ -1818,7 +1831,7 @@ namespace MinecraftClient.Protocol.Handlers
/// <returns>Max length, in characters</returns> /// <returns>Max length, in characters</returns>
public int GetMaxChatMessageLength() public int GetMaxChatMessageLength()
{ {
return protocolversion > MC_1_10_Version return protocolVersion > MC_1_10_Version
? 256 ? 256
: 100; : 100;
} }
@ -1832,7 +1845,7 @@ namespace MinecraftClient.Protocol.Handlers
/// <returns>Minecraft Protocol version number</returns> /// <returns>Minecraft Protocol version number</returns>
public int GetProtocolVersion() public int GetProtocolVersion()
{ {
return protocolversion; return protocolVersion;
} }
@ -1953,7 +1966,7 @@ namespace MinecraftClient.Protocol.Handlers
return true; return true;
// Process Chat Command - 1.19 and above // Process Chat Command - 1.19 and above
if (protocolversion >= MC_1_19_Version && message.StartsWith('/')) if (protocolVersion >= MC_1_19_Version && message.StartsWith('/'))
return SendChatCommand(message[1..], playerKeyPair); return SendChatCommand(message[1..], playerKeyPair);
try try
@ -1963,7 +1976,7 @@ namespace MinecraftClient.Protocol.Handlers
// Message: String (up to 256 chars) // Message: String (up to 256 chars)
fields.AddRange(dataTypes.GetString(message)); fields.AddRange(dataTypes.GetString(message));
if (protocolversion >= MC_1_19_Version) if (protocolVersion >= MC_1_19_Version)
{ {
// Timestamp: Instant(Long) // Timestamp: Instant(Long)
DateTimeOffset timeNow = DateTimeOffset.UtcNow; DateTimeOffset timeNow = DateTimeOffset.UtcNow;
@ -2041,7 +2054,7 @@ namespace MinecraftClient.Protocol.Handlers
return false; return false;
// Plugin channels were significantly changed between Minecraft 1.12 and 1.13 // Plugin channels were significantly changed between Minecraft 1.12 and 1.13
// https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14132#Plugin_Channels // https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14132#Plugin_Channels
if (protocolversion >= MC_1_13_Version) if (protocolVersion >= MC_1_13_Version)
{ {
return SendPluginChannelPacket("minecraft:brand", dataTypes.GetString(brandInfo)); return SendPluginChannelPacket("minecraft:brand", dataTypes.GetString(brandInfo));
} }
@ -2069,26 +2082,26 @@ namespace MinecraftClient.Protocol.Handlers
List<byte> fields = new List<byte>(); List<byte> fields = new List<byte>();
fields.AddRange(dataTypes.GetString(language)); fields.AddRange(dataTypes.GetString(language));
fields.Add(viewDistance); fields.Add(viewDistance);
fields.AddRange(protocolversion >= MC_1_9_Version fields.AddRange(protocolVersion >= MC_1_9_Version
? dataTypes.GetVarInt(chatMode) ? dataTypes.GetVarInt(chatMode)
: new byte[] { chatMode }); : new byte[] { chatMode });
fields.Add(chatColors ? (byte)1 : (byte)0); fields.Add(chatColors ? (byte)1 : (byte)0);
if (protocolversion < MC_1_8_Version) if (protocolVersion < MC_1_8_Version)
{ {
fields.Add(difficulty); fields.Add(difficulty);
fields.Add((byte)(skinParts & 0x1)); //show cape fields.Add((byte)(skinParts & 0x1)); //show cape
} }
else fields.Add(skinParts); else fields.Add(skinParts);
if (protocolversion >= MC_1_9_Version) if (protocolVersion >= MC_1_9_Version)
fields.AddRange(dataTypes.GetVarInt(mainHand)); fields.AddRange(dataTypes.GetVarInt(mainHand));
if (protocolversion >= MC_1_17_Version) if (protocolVersion >= MC_1_17_Version)
{ {
if (protocolversion >= MC_1_18_1_Version) if (protocolVersion >= MC_1_18_1_Version)
fields.Add(0); // 1.18 and above - Enable text filtering. (Always false) fields.Add(0); // 1.18 and above - Enable text filtering. (Always false)
else else
fields.Add(1); // 1.17 and 1.17.1 - Disable text filtering. (Always true) fields.Add(1); // 1.17 and 1.17.1 - Disable text filtering. (Always true)
} }
if (protocolversion >= MC_1_18_1_Version) if (protocolVersion >= MC_1_18_1_Version)
fields.Add(1); // 1.18 and above - Allow server listings fields.Add(1); // 1.18 and above - Allow server listings
SendPacket(PacketTypesOut.ClientSettings, fields); SendPacket(PacketTypesOut.ClientSettings, fields);
} }
@ -2124,7 +2137,7 @@ namespace MinecraftClient.Protocol.Handlers
SendPacket(packetType, dataTypes.ConcatBytes( SendPacket(packetType, dataTypes.ConcatBytes(
dataTypes.GetDouble(location.X), dataTypes.GetDouble(location.X),
dataTypes.GetDouble(location.Y), dataTypes.GetDouble(location.Y),
protocolversion < MC_1_8_Version protocolVersion < MC_1_8_Version
? dataTypes.GetDouble(location.Y + 1.62) ? dataTypes.GetDouble(location.Y + 1.62)
: new byte[0], : new byte[0],
dataTypes.GetDouble(location.Z), dataTypes.GetDouble(location.Z),
@ -2150,7 +2163,7 @@ namespace MinecraftClient.Protocol.Handlers
{ {
// In 1.7, length needs to be included. // In 1.7, length needs to be included.
// In 1.8, it must not be. // In 1.8, it must not be.
if (protocolversion < MC_1_8_Version) if (protocolVersion < MC_1_8_Version)
{ {
byte[] length = BitConverter.GetBytes((short)data.Length); byte[] length = BitConverter.GetBytes((short)data.Length);
Array.Reverse(length); Array.Reverse(length);
@ -2205,7 +2218,7 @@ namespace MinecraftClient.Protocol.Handlers
// Is player Sneaking (Only 1.16 and above) // Is player Sneaking (Only 1.16 and above)
// Currently hardcoded to false // Currently hardcoded to false
// TODO: Update to reflect the real player state // TODO: Update to reflect the real player state
if (protocolversion >= MC_1_16_Version) if (protocolVersion >= MC_1_16_Version)
fields.AddRange(dataTypes.GetBool(false)); fields.AddRange(dataTypes.GetBool(false));
SendPacket(PacketTypesOut.InteractEntity, fields); SendPacket(PacketTypesOut.InteractEntity, fields);
@ -2231,7 +2244,7 @@ namespace MinecraftClient.Protocol.Handlers
// Is player Sneaking (Only 1.16 and above) // Is player Sneaking (Only 1.16 and above)
// Currently hardcoded to false // Currently hardcoded to false
// TODO: Update to reflect the real player state // TODO: Update to reflect the real player state
if (protocolversion >= MC_1_16_Version) if (protocolVersion >= MC_1_16_Version)
fields.AddRange(dataTypes.GetBool(false)); fields.AddRange(dataTypes.GetBool(false));
SendPacket(PacketTypesOut.InteractEntity, fields); SendPacket(PacketTypesOut.InteractEntity, fields);
return true; return true;
@ -2251,7 +2264,7 @@ namespace MinecraftClient.Protocol.Handlers
// Is player Sneaking (Only 1.16 and above) // Is player Sneaking (Only 1.16 and above)
// Currently hardcoded to false // Currently hardcoded to false
// TODO: Update to reflect the real player state // TODO: Update to reflect the real player state
if (protocolversion >= MC_1_16_Version) if (protocolVersion >= MC_1_16_Version)
fields.AddRange(dataTypes.GetBool(false)); fields.AddRange(dataTypes.GetBool(false));
SendPacket(PacketTypesOut.InteractEntity, fields); SendPacket(PacketTypesOut.InteractEntity, fields);
return true; return true;
@ -2267,7 +2280,7 @@ namespace MinecraftClient.Protocol.Handlers
public bool SendUseItem(int hand, int sequenceId) public bool SendUseItem(int hand, int sequenceId)
{ {
if (protocolversion < MC_1_9_Version) if (protocolVersion < MC_1_9_Version)
return false; // Packet does not exist prior to MC 1.9 return false; // Packet does not exist prior to MC 1.9
// According to https://wiki.vg/index.php?title=Protocol&oldid=5486#Player_Block_Placement // According to https://wiki.vg/index.php?title=Protocol&oldid=5486#Player_Block_Placement
// MC 1.7 does this using Player Block Placement with special values // MC 1.7 does this using Player Block Placement with special values
@ -2276,7 +2289,7 @@ namespace MinecraftClient.Protocol.Handlers
{ {
List<byte> packet = new List<byte>(); List<byte> packet = new List<byte>();
packet.AddRange(dataTypes.GetVarInt(hand)); packet.AddRange(dataTypes.GetVarInt(hand));
if (protocolversion >= MC_1_19_Version) if (protocolVersion >= MC_1_19_Version)
packet.AddRange(dataTypes.GetVarInt(sequenceId)); packet.AddRange(dataTypes.GetVarInt(sequenceId));
SendPacket(PacketTypesOut.UseItem, packet); SendPacket(PacketTypesOut.UseItem, packet);
return true; return true;
@ -2294,7 +2307,7 @@ namespace MinecraftClient.Protocol.Handlers
packet.AddRange(dataTypes.GetVarInt(status)); packet.AddRange(dataTypes.GetVarInt(status));
packet.AddRange(dataTypes.GetLocation(location)); packet.AddRange(dataTypes.GetLocation(location));
packet.AddRange(dataTypes.GetVarInt(dataTypes.GetBlockFace(face))); packet.AddRange(dataTypes.GetVarInt(dataTypes.GetBlockFace(face)));
if (protocolversion >= MC_1_19_Version) if (protocolVersion >= MC_1_19_Version)
packet.AddRange(dataTypes.GetVarInt(sequenceId)); packet.AddRange(dataTypes.GetVarInt(sequenceId));
SendPacket(PacketTypesOut.PlayerDigging, packet); SendPacket(PacketTypesOut.PlayerDigging, packet);
return true; return true;
@ -2306,7 +2319,7 @@ namespace MinecraftClient.Protocol.Handlers
public bool SendPlayerBlockPlacement(int hand, Location location, Direction face, int sequenceId) public bool SendPlayerBlockPlacement(int hand, Location location, Direction face, int sequenceId)
{ {
if (protocolversion < MC_1_14_Version) if (protocolVersion < MC_1_14_Version)
return false; // NOT IMPLEMENTED for older MC versions return false; // NOT IMPLEMENTED for older MC versions
try try
{ {
@ -2318,7 +2331,7 @@ namespace MinecraftClient.Protocol.Handlers
packet.AddRange(dataTypes.GetFloat(0.5f)); // cursorY packet.AddRange(dataTypes.GetFloat(0.5f)); // cursorY
packet.AddRange(dataTypes.GetFloat(0.5f)); // cursorZ packet.AddRange(dataTypes.GetFloat(0.5f)); // cursorZ
packet.Add(0); // insideBlock = false; packet.Add(0); // insideBlock = false;
if (protocolversion >= MC_1_19_Version) if (protocolVersion >= MC_1_19_Version)
packet.AddRange(dataTypes.GetVarInt(sequenceId)); packet.AddRange(dataTypes.GetVarInt(sequenceId));
SendPacket(PacketTypesOut.PlayerBlockPlacement, packet); SendPacket(PacketTypesOut.PlayerBlockPlacement, packet);
return true; return true;
@ -2381,13 +2394,13 @@ namespace MinecraftClient.Protocol.Handlers
packet.Add((byte)windowId); // Window ID packet.Add((byte)windowId); // Window ID
// 1.18+ // 1.18+
if (protocolversion >= MC_1_18_1_Version) if (protocolVersion >= MC_1_18_1_Version)
{ {
packet.AddRange(dataTypes.GetVarInt(stateId)); // State ID packet.AddRange(dataTypes.GetVarInt(stateId)); // State ID
packet.AddRange(dataTypes.GetShort((short)slotId)); // Slot ID packet.AddRange(dataTypes.GetShort((short)slotId)); // Slot ID
} }
// 1.17.1 // 1.17.1
else if (protocolversion == MC_1_17_1_Version) else if (protocolVersion == MC_1_17_1_Version)
{ {
packet.AddRange(dataTypes.GetShort((short)slotId)); // Slot ID packet.AddRange(dataTypes.GetShort((short)slotId)); // Slot ID
packet.AddRange(dataTypes.GetVarInt(stateId)); // State ID packet.AddRange(dataTypes.GetVarInt(stateId)); // State ID
@ -2400,15 +2413,15 @@ namespace MinecraftClient.Protocol.Handlers
packet.Add(button); // Button packet.Add(button); // Button
if (protocolversion < MC_1_17_Version) if (protocolVersion < MC_1_17_Version)
packet.AddRange(dataTypes.GetShort(actionNumber)); packet.AddRange(dataTypes.GetShort(actionNumber));
if (protocolversion >= MC_1_9_Version) if (protocolVersion >= MC_1_9_Version)
packet.AddRange(dataTypes.GetVarInt(mode)); // Mode packet.AddRange(dataTypes.GetVarInt(mode)); // Mode
else packet.Add(mode); else packet.Add(mode);
// 1.17+ Array of changed slots // 1.17+ Array of changed slots
if (protocolversion >= MC_1_17_Version) if (protocolVersion >= MC_1_17_Version)
{ {
packet.AddRange(dataTypes.GetVarInt(changedSlots.Count)); // Length of the array packet.AddRange(dataTypes.GetVarInt(changedSlots.Count)); // Length of the array
foreach (var slot in changedSlots) foreach (var slot in changedSlots)
@ -2451,12 +2464,12 @@ namespace MinecraftClient.Protocol.Handlers
{ {
List<byte> packet = new List<byte>(); List<byte> packet = new List<byte>();
if (protocolversion < MC_1_8_Version) if (protocolVersion < MC_1_8_Version)
{ {
packet.AddRange(dataTypes.GetInt(playerid)); packet.AddRange(dataTypes.GetInt(playerid));
packet.Add((byte)1); // Swing arm packet.Add((byte)1); // Swing arm
} }
else if (protocolversion < MC_1_9_Version) else if (protocolVersion < MC_1_9_Version)
{ {
// No fields in 1.8.X // No fields in 1.8.X
} }
@ -2524,7 +2537,7 @@ namespace MinecraftClient.Protocol.Handlers
public bool UpdateCommandBlock(Location location, string command, CommandBlockMode mode, CommandBlockFlags flags) public bool UpdateCommandBlock(Location location, string command, CommandBlockMode mode, CommandBlockFlags flags)
{ {
if (protocolversion <= MC_1_13_Version) if (protocolVersion <= MC_1_13_Version)
{ {
try try
{ {
@ -2562,7 +2575,7 @@ namespace MinecraftClient.Protocol.Handlers
public bool SelectTrade(int selectedSlot) public bool SelectTrade(int selectedSlot)
{ {
// MC 1.13 or greater // MC 1.13 or greater
if (protocolversion >= MC_1_13_Version) if (protocolVersion >= MC_1_13_Version)
{ {
try try
{ {
@ -2581,7 +2594,7 @@ namespace MinecraftClient.Protocol.Handlers
public bool SendSpectate(Guid UUID) public bool SendSpectate(Guid UUID)
{ {
// MC 1.8 or greater // MC 1.8 or greater
if (protocolversion >= MC_1_8_Version) if (protocolVersion >= MC_1_8_Version)
{ {
try try
{ {