Cuberite
A lightweight, fast and extensible game server for Minecraft
Protocol_1_13.cpp
Go to the documentation of this file.
1 
2 // Protocol_1_13.cpp
3 
4 /*
5 Implements the 1.13 protocol classes:
6 - release 1.13 protocol (#393)
7 - release 1.13.1 protocol (#401)
8 - release 1.13.2 protocol (#404)
9 */
10 
11 #include "Globals.h"
12 #include "Protocol_1_13.h"
13 
14 #include "../Entities/Boat.h"
15 #include "../Entities/EnderCrystal.h"
16 #include "../Entities/Minecart.h"
17 #include "../Entities/Pickup.h"
18 #include "../Entities/Player.h"
19 #include "../Entities/ItemFrame.h"
20 #include "../Entities/ArrowEntity.h"
21 #include "../Entities/FireworkEntity.h"
22 #include "../Entities/SplashPotionEntity.h"
23 
24 #include "../Mobs/IncludeAllMonsters.h"
25 
26 #include "../CompositeChat.h"
27 #include "../ClientHandle.h"
28 #include "../Root.h"
29 #include "../Server.h"
30 #include "../World.h"
31 #include "../JsonUtils.h"
32 #include "../WorldStorage/FastNBT.h"
34 
35 #include "../Bindings/PluginManager.h"
36 
37 #include "Palettes/Palette_1_13.h"
39 
40 
41 
42 
43 
45 // cProtocol_1_13:
46 
47 void cProtocol_1_13::SendBlockChange(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
48 {
49  cPacketizer Pkt(*this, pktBlockChange);
50  Pkt.WriteXYZPosition64(a_BlockPos);
51  Pkt.WriteVarInt32(GetProtocolBlockType(a_BlockType, a_BlockMeta));
52 }
53 
54 
55 
56 
57 
58 void cProtocol_1_13::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes)
59 {
60  ASSERT(m_State == 3); // In game mode?
61 
62  cPacketizer Pkt(*this, pktBlockChanges);
63  Pkt.WriteBEInt32(a_ChunkX);
64  Pkt.WriteBEInt32(a_ChunkZ);
65  Pkt.WriteVarInt32(static_cast<UInt32>(a_Changes.size()));
66 
67  for (const auto & Change : a_Changes)
68  {
69  Int16 Coords = static_cast<Int16>(Change.m_RelY | (Change.m_RelZ << 8) | (Change.m_RelX << 12));
70  Pkt.WriteBEInt16(Coords);
71  Pkt.WriteVarInt32(GetProtocolBlockType(Change.m_BlockType, Change.m_BlockMeta));
72  }
73 }
74 
75 
76 
77 
78 
79 void cProtocol_1_13::SendMapData(const cMap & a_Map, int a_DataStartX, int a_DataStartY)
80 {
81  // TODO
82 }
83 
84 
85 
86 
87 
89 {
90  // TODO
91 }
92 
93 
94 
95 
96 
97 void cProtocol_1_13::SendParticleEffect(const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data)
98 {
99  // This packet is unchanged since 1.8
100  // However we are hardcoding a string-to-id mapping inside there
101  // TODO: make a virtual enum-to-id mapping
102 }
103 
104 
105 
106 
107 
108 void cProtocol_1_13::SendScoreboardObjective(const AString & a_Name, const AString & a_DisplayName, Byte a_Mode)
109 {
110  // TODO
111 }
112 
113 
114 
115 
116 
118 {
119  ASSERT(m_State == 3); // In game mode?
120 
121  UInt32 Size = 0;
122 
123  for (const auto & [Statistic, Value] : a_Manager.Custom)
124  {
125  // Client balks at out-of-range values so there is no good default value.
126  // We're forced to not send the statistics this protocol version doesn't support.
127 
128  if (GetProtocolStatisticType(Statistic) != static_cast<UInt32>(-1))
129  {
130  Size++;
131  }
132  }
133 
134  // No need to check Size != 0
135  // Assume that the vast majority of the time there's at least one statistic to send
136 
137  cPacketizer Pkt(*this, pktStatistics);
138  Pkt.WriteVarInt32(Size);
139 
140  for (const auto & [Statistic, Value] : a_Manager.Custom)
141  {
142  const auto ID = GetProtocolStatisticType(Statistic);
143  if (ID == static_cast<UInt32>(-1))
144  {
145  // Unsupported, don't send:
146  continue;
147  }
148 
149  Pkt.WriteVarInt32(8); // "Custom" category.
150  Pkt.WriteVarInt32(ID);
151  Pkt.WriteVarInt32(static_cast<UInt32>(Value));
152  }
153 }
154 
155 
156 
157 
158 
160 {
161  // TODO
162 }
163 
164 
165 
166 
167 
169 {
170  ASSERT(m_State == 3); // In game mode?
171 
172  Byte Action;
173  switch (a_BlockEntity.GetBlockType())
174  {
175  case E_BLOCK_CHEST:
177  case E_BLOCK_END_PORTAL:
179  {
180  // The ones with a action of 0 is just a workaround to send the block entities to a client.
181  // Todo: 18.09.2020 - remove this when block entities are transmitted in the ChunkData packet - 12xx12
182  Action = 0;
183  break;
184  }
185 
186  case E_BLOCK_MOB_SPAWNER: Action = 1; break; // Update mob spawner spinny mob thing
187  case E_BLOCK_COMMAND_BLOCK: Action = 2; break; // Update command block text
188  case E_BLOCK_BEACON: Action = 3; break; // Update beacon entity
189  case E_BLOCK_HEAD: Action = 4; break; // Update Mobhead entity
190  // case E_BLOCK_CONDUIT: Action = 5; break; // Update Conduit entity
192  case E_BLOCK_WALL_BANNER: Action = 6; break; // Update banner entity
193  // case Structure Block: Action = 7; break; // Update Structure tile entity
194  case E_BLOCK_END_GATEWAY: Action = 8; break; // Update destination for a end gateway entity
195  case E_BLOCK_SIGN_POST: Action = 9; break; // Update sign entity
196  // case E_BLOCK_SHULKER_BOX: Action = 10; break; // sets shulker box - not used just here if anyone is confused from reading the protocol wiki
197  case E_BLOCK_BED: Action = 11; break; // Update bed color
198 
199  default: return; // Block entities change between versions
200  }
201 
202  cPacketizer Pkt(*this, pktUpdateBlockEntity);
203  Pkt.WriteXYZPosition64(a_BlockEntity.GetPosX(), a_BlockEntity.GetPosY(), a_BlockEntity.GetPosZ());
204  Pkt.WriteBEUInt8(Action);
205 
206  cFastNBTWriter Writer;
207  WriteBlockEntity(Writer, a_BlockEntity);
208  Writer.Finish();
209  Pkt.WriteBuf(Writer.GetResult());
210 }
211 
212 
213 
214 
215 
217 {
218  const UInt8 Entity = 6;
219  const UInt8 Living = Entity + 5;
220  const UInt8 Insentient = Living + 1;
221  const UInt8 Ageable = Insentient + 1;
222  const UInt8 AbstractHorse = Ageable + 2;
223  const UInt8 ChestedHorse = AbstractHorse + 1;
224  const UInt8 TameableAnimal = Ageable + 2;
225  const UInt8 Minecart = Entity + 6;
226 
227  switch (a_Metadata)
228  {
229  case EntityMetadata::EntityFlags: return 0;
230  case EntityMetadata::EntityAir: return 1;
231  case EntityMetadata::EntityCustomName: return 2;
233  case EntityMetadata::EntitySilent: return 4;
234  case EntityMetadata::EntityNoGravity: return 5;
235  case EntityMetadata::PotionThrown: return Entity;
236  case EntityMetadata::FallingBlockPosition: return Entity;
237  case EntityMetadata::AreaEffectCloudRadius: return Entity;
238  case EntityMetadata::AreaEffectCloudColor: return Entity + 1;
239  case EntityMetadata::AreaEffectCloudSinglePointEffect: return Entity + 2;
240  case EntityMetadata::AreaEffectCloudParticleId: return Entity + 3;
241  case EntityMetadata::ArrowFlags: return Entity;
242  case EntityMetadata::TippedArrowColor: return Entity + 1;
243  case EntityMetadata::BoatLastHitTime: return Entity;
244  case EntityMetadata::BoatForwardDirection: return Entity + 1;
245  case EntityMetadata::BoatDamageTaken: return Entity + 2;
246  case EntityMetadata::BoatType: return Entity + 3;
247  case EntityMetadata::BoatLeftPaddleTurning: return Entity + 4;
248  case EntityMetadata::BoatRightPaddleTurning: return Entity + 5;
249  case EntityMetadata::BoatSplashTimer: return Entity + 6;
250  case EntityMetadata::EnderCrystalBeamTarget: return Entity;
251  case EntityMetadata::EnderCrystalShowBottom: return Entity + 1;
252  case EntityMetadata::WitherSkullInvulnerable: return Entity;
253  case EntityMetadata::FireworkInfo: return Entity;
254  case EntityMetadata::FireworkBoostedEntityId: return Entity + 1;
255  case EntityMetadata::ItemFrameItem: return Entity;
256  case EntityMetadata::ItemFrameRotation: return Entity + 1;
257  case EntityMetadata::ItemItem: return Entity;
258  case EntityMetadata::LivingActiveHand: return Entity;
259  case EntityMetadata::LivingHealth: return Entity + 1;
260  case EntityMetadata::LivingPotionEffectColor: return Entity + 2;
261  case EntityMetadata::LivingPotionEffectAmbient: return Entity + 3;
262  case EntityMetadata::LivingNumberOfArrows: return Entity + 4;
263  case EntityMetadata::PlayerAdditionalHearts: return Living;
264  case EntityMetadata::PlayerScore: return Living + 1;
265  case EntityMetadata::PlayerDisplayedSkinParts: return Living + 2;
266  case EntityMetadata::PlayerMainHand: return Living + 3;
267  case EntityMetadata::ArmorStandStatus: return Living;
268  case EntityMetadata::ArmorStandHeadRotation: return Living + 1;
269  case EntityMetadata::ArmorStandBodyRotation: return Living + 2;
270  case EntityMetadata::ArmorStandLeftArmRotation: return Living + 3;
271  case EntityMetadata::ArmorStandRightArmRotation: return Living + 4;
272  case EntityMetadata::ArmorStandLeftLegRotation: return Living + 5;
273  case EntityMetadata::ArmorStandRightLegRotation: return Living + 6;
274  case EntityMetadata::InsentientFlags: return Living;
275  case EntityMetadata::BatHanging: return Insentient;
276  case EntityMetadata::AgeableIsBaby: return Insentient;
277  case EntityMetadata::AbstractHorseFlags: return Ageable;
278  case EntityMetadata::AbstractHorseOwner: return Ageable + 1;
279  case EntityMetadata::HorseVariant: return AbstractHorse;
280  case EntityMetadata::HorseArmour: return AbstractHorse + 1;
281  case EntityMetadata::ChestedHorseChested: return AbstractHorse;
282  case EntityMetadata::LlamaStrength: return ChestedHorse;
283  case EntityMetadata::LlamaCarpetColor: return ChestedHorse + 1;
284  case EntityMetadata::LlamaVariant: return ChestedHorse + 2;
285  case EntityMetadata::PigHasSaddle: return Ageable;
286  case EntityMetadata::PigTotalCarrotOnAStickBoost: return Ageable + 1;
287  case EntityMetadata::RabbitType: return Ageable;
288  case EntityMetadata::PolarBearStanding: return Ageable;
289  case EntityMetadata::SheepFlags: return Ageable;
290  case EntityMetadata::TameableAnimalFlags: return Ageable;
291  case EntityMetadata::TameableAnimalOwner: return Ageable + 1;
292  case EntityMetadata::OcelotType: return TameableAnimal;
293  case EntityMetadata::WolfDamageTaken: return TameableAnimal;
294  case EntityMetadata::WolfBegging: return TameableAnimal + 1;
295  case EntityMetadata::WolfCollarColour: return TameableAnimal + 2;
296  case EntityMetadata::VillagerProfession: return Ageable;
297  case EntityMetadata::IronGolemPlayerCreated: return Insentient;
298  case EntityMetadata::ShulkerFacingDirection: return Insentient;
299  case EntityMetadata::ShulkerAttachmentFallingBlockPosition: return Insentient + 1;
300  case EntityMetadata::ShulkerShieldHeight: return Insentient + 2;
301  case EntityMetadata::BlazeOnFire: return Insentient;
302  case EntityMetadata::CreeperState: return Insentient;
303  case EntityMetadata::CreeperPowered: return Insentient + 1;
304  case EntityMetadata::CreeperIgnited: return Insentient + 2;
305  case EntityMetadata::GuardianStatus: return Insentient;
306  case EntityMetadata::GuardianTarget: return Insentient + 1;
307  case EntityMetadata::IllagerFlags: return Insentient;
308  case EntityMetadata::SpeIlagerSpell: return Insentient + 1;
309  case EntityMetadata::VexFlags: return Insentient;
310  case EntityMetadata::AbstractSkeletonArmsSwinging: return Insentient;
311  case EntityMetadata::SpiderClimbing: return Insentient;
312  case EntityMetadata::WitchAggresive: return Insentient;
313  case EntityMetadata::WitherFirstHeadTarget: return Insentient;
314  case EntityMetadata::WitherSecondHeadTarget: return Insentient + 1;
315  case EntityMetadata::WitherThirdHeadTarget: return Insentient + 2;
316  case EntityMetadata::WitherInvulnerableTimer: return Insentient + 3;
317  case EntityMetadata::ZombieIsBaby: return Insentient;
318  case EntityMetadata::ZombieHandsRisedUp: return Insentient + 2;
319  case EntityMetadata::ZombieVillagerConverting: return Insentient + 4;
320  case EntityMetadata::ZombieVillagerProfession: return Insentient + 5;
321  case EntityMetadata::EndermanCarriedBlock: return Insentient;
322  case EntityMetadata::EndermanScreaming: return Insentient + 1;
323  case EntityMetadata::EnderDragonDragonPhase: return Insentient;
324  case EntityMetadata::GhastAttacking: return Insentient;
325  case EntityMetadata::SlimeSize: return Insentient;
326  case EntityMetadata::MinecartShakingPower: return Entity;
327  case EntityMetadata::MinecartShakingDirection: return Entity + 1;
328  case EntityMetadata::MinecartShakingMultiplier: return Entity + 2;
329  case EntityMetadata::MinecartBlockIDMeta: return Entity + 3;
330  case EntityMetadata::MinecartBlockY: return Entity + 4;
331  case EntityMetadata::MinecartShowBlock: return Entity + 5;
335  case EntityMetadata::TNTPrimedFuseTime: return Entity;
336 
341 
342  default:
343  break;
344  }
345  UNREACHABLE("Retrieved invalid metadata for protocol");
346 }
347 
348 
349 
350 
351 
353 {
354  switch (a_FieldType)
355  {
356  case EntityMetadataType::Byte: return 0;
357  case EntityMetadataType::VarInt: return 1;
358  case EntityMetadataType::Float: return 2;
359  case EntityMetadataType::String: return 3;
360  case EntityMetadataType::Chat: return 4;
361  case EntityMetadataType::OptChat: return 5;
362  case EntityMetadataType::Item: return 6;
363  case EntityMetadataType::Boolean: return 7;
364  case EntityMetadataType::Rotation: return 8;
365  case EntityMetadataType::Position: return 9;
366  case EntityMetadataType::OptPosition: return 10;
367  case EntityMetadataType::Direction: return 11;
368  case EntityMetadataType::OptUUID: return 12;
369  case EntityMetadataType::OptBlockID: return 13;
370  case EntityMetadataType::NBT: return 14;
371  case EntityMetadataType::Particle: return 15;
372  case EntityMetadataType::VillagerData: return 16;
373  case EntityMetadataType::OptVarInt: return 17;
374  case EntityMetadataType::Pose: return 18;
375  }
376  UNREACHABLE("Translated invalid metadata type for protocol");
377 }
378 
379 
380 
381 
382 
383 std::pair<short, short> cProtocol_1_13::GetItemFromProtocolID(UInt32 a_ProtocolID) const
384 {
385  return PaletteUpgrade::ToItem(Palette_1_13::ToItem(a_ProtocolID));
386 }
387 
388 
389 
390 
391 
393 {
394  switch (a_PacketType)
395  {
396  case pktAttachEntity: return 0x46;
397  case pktBlockChanges: return 0x0f;
398  case pktCameraSetTo: return 0x3c;
399  case pktChatRaw: return 0x0e;
400  case pktCollectEntity: return 0x4f;
401  case pktDestroyEntity: return 0x35;
402  case pktDisconnectDuringGame: return 0x1b;
403  case pktEditSign: return 0x2c;
404  case pktEntityEffect: return 0x53;
405  case pktEntityEquipment: return 0x42;
406  case pktEntityHeadLook: return 0x39;
407  case pktEntityLook: return 0x2a;
408  case pktEntityMeta: return 0x3f;
409  case pktEntityProperties: return 0x52;
410  case pktEntityRelMove: return 0x28;
411  case pktEntityRelMoveLook: return 0x29;
412  case pktEntityStatus: return 0x1c;
413  case pktEntityVelocity: return 0x41;
414  case pktExperience: return 0x43;
415  case pktExplosion: return 0x1e;
416  case pktGameMode: return 0x20;
417  case pktHeldItemChange: return 0x3d;
418  case pktInventorySlot: return 0x17;
419  case pktJoinGame: return 0x25;
420  case pktKeepAlive: return 0x21;
421  case pktLeashEntity: return 0x40;
422  case pktMapData: return 0x26;
423  case pktParticleEffect: return 0x24;
424  case pktPlayerAbilities: return 0x2e;
425  case pktPlayerList: return 0x30;
426  case pktPlayerListHeaderFooter: return 0x4e;
427  case pktPlayerMoveLook: return 0x32;
428  case pktPluginMessage: return 0x19;
429  case pktRemoveEntityEffect: return 0x36;
430  case pktRespawn: return 0x38;
431  case pktScoreboardObjective: return 0x45;
432  case pktSoundEffect: return 0x1a;
433  case pktSoundParticleEffect: return 0x23;
434  case pktSpawnPosition: return 0x49;
435  case pktTabCompletionResults: return 0x10;
436  case pktTeleportEntity: return 0x50;
437  case pktTimeUpdate: return 0x4a;
438  case pktTitle: return 0x4b;
439  case pktUnloadChunk: return 0x1f;
440  case pktUnlockRecipe: return 0x32;
441  case pktUpdateHealth: return 0x44;
442  case pktUpdateScore: return 0x48;
444  case pktUseBed: return 0x33;
445  case pktWeather: return 0x20;
446  case pktWindowClose: return 0x13;
447  case pktWindowItems: return 0x15;
448  case pktWindowOpen: return 0x14;
449  case pktWindowProperty: return 0x16;
450  default: return Super::GetPacketID(a_PacketType);
451  }
452 }
453 
454 
455 
456 
457 
459 {
460  return Palette_1_13::From(PaletteUpgrade::FromBlock(a_BlockType, a_Meta));
461 }
462 
463 
464 
465 
466 
467 signed char cProtocol_1_13::GetProtocolEntityStatus(const EntityAnimation a_Animation) const
468 {
469  switch (a_Animation)
470  {
472  default: return Super::GetProtocolEntityStatus(a_Animation);
473  }
474 }
475 
476 
477 
478 
479 
480 UInt32 cProtocol_1_13::GetProtocolItemType(short a_ItemID, short a_ItemDamage) const
481 {
482  return Palette_1_13::From(PaletteUpgrade::FromItem(a_ItemID, a_ItemDamage));
483 }
484 
485 
486 
487 
488 
490 {
491  switch (a_MobType)
492  {
493  // Map invalid type to Giant for easy debugging (if this ever spawns, something has gone very wrong)
494  case mtInvalidType: return 27;
495  case mtBat: return 3;
496  case mtCat: return 48;
497  case mtBlaze: return 4;
498  case mtCaveSpider: return 6;
499  case mtChicken: return 7;
500  case mtCod: return 8;
501  case mtCow: return 9;
502  case mtCreeper: return 10;
503  case mtDonkey: return 11;
504  case mtDolphin: return 12;
505  case mtDrowned: return 14;
506  case mtElderGuardian: return 15;
507  case mtEnderDragon: return 17;
508  case mtEnderman: return 18;
509  case mtEndermite: return 19;
510  case mtEvoker: return 21;
511  case mtGhast: return 26;
512  case mtGiant: return 27;
513  case mtGuardian: return 28;
514  case mtHorse: return 29;
515  case mtHusk: return 30;
516  case mtIllusioner: return 31;
517  case mtIronGolem: return 80;
518  case mtLlama: return 36;
519  case mtMagmaCube: return 38;
520  case mtMule: return 46;
521  case mtMooshroom: return 47;
522  case mtOcelot: return 48;
523  case mtParrot: return 50;
524  case mtPhantom: return 90;
525  case mtPig: return 51;
526  case mtPufferfish: return 52;
527  case mtPolarBear: return 54;
528  case mtRabbit: return 56;
529  case mtSalmon: return 57;
530  case mtSheep: return 58;
531  case mtShulker: return 59;
532  case mtSilverfish: return 61;
533  case mtSkeleton: return 62;
534  case mtSkeletonHorse: return 63;
535  case mtSlime: return 64;
536  case mtSnowGolem: return 66;
537  case mtSpider: return 69;
538  case mtSquid: return 70;
539  case mtStray: return 71;
540  case mtTropicalFish: return 72;
541  case mtTurtle: return 73;
542  case mtVex: return 78;
543  case mtVillager: return 79;
544  case mtVindicator: return 81;
545  case mtWitch: return 82;
546  case mtWither: return 83;
547  case mtWitherSkeleton: return 84;
548  case mtWolf: return 86;
549  case mtZombie: return 87;
550  case mtZombiePigman: return 53;
551  case mtZombieHorse: return 88;
552  case mtZombieVillager: return 89;
553  default: return 0;
554  }
555 }
556 
557 
558 
559 
560 
562 {
563  return Palette_1_13::From(a_Statistic);
564 }
565 
566 
567 
568 
569 
571 {
572  return Version::v1_13;
573 }
574 
575 
576 
577 
578 
579 bool cProtocol_1_13::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
580 {
581  if (m_State != 3)
582  {
583  return Super::HandlePacket(a_ByteBuffer, a_PacketType);
584  }
585 
586  // Game
587  switch (a_PacketType)
588  {
589  case 0x00: HandleConfirmTeleport(a_ByteBuffer); return true;
590  case 0x05: HandlePacketTabComplete(a_ByteBuffer); return true;
591  case 0x02: HandlePacketChatMessage(a_ByteBuffer); return true;
592  case 0x03: HandlePacketClientStatus(a_ByteBuffer); return true;
593  case 0x04: HandlePacketClientSettings(a_ByteBuffer); return true;
594  case 0x06: break; // Confirm transaction - not used in Cuberite
595  case 0x07: HandlePacketEnchantItem(a_ByteBuffer); return true;
596  case 0x08: HandlePacketWindowClick(a_ByteBuffer); return true;
597  case 0x09: HandlePacketWindowClose(a_ByteBuffer); return true;
598  case 0x0a: HandlePacketPluginMessage(a_ByteBuffer); return true;
599  case 0x0d: HandlePacketUseEntity(a_ByteBuffer); return true;
600  case 0x0e: HandlePacketKeepAlive(a_ByteBuffer); return true;
601  case 0x0f: HandlePacketPlayer(a_ByteBuffer); return true;
602  case 0x10: HandlePacketPlayerPos(a_ByteBuffer); return true;
603  case 0x11: HandlePacketPlayerPosLook(a_ByteBuffer); return true;
604  case 0x12: HandlePacketPlayerLook(a_ByteBuffer); return true;
605  case 0x13: HandlePacketVehicleMove(a_ByteBuffer); return true;
606  case 0x14: HandlePacketBoatSteer(a_ByteBuffer); return true;
607  case 0x15: break; // Pick item - not yet implemented
608  case 0x16: break; // Craft Recipe Request - not yet implemented
609  case 0x17: HandlePacketPlayerAbilities(a_ByteBuffer); return true;
610  case 0x18: HandlePacketBlockDig(a_ByteBuffer); return true;
611  case 0x19: HandlePacketEntityAction(a_ByteBuffer); return true;
612  case 0x1a: HandlePacketSteerVehicle(a_ByteBuffer); return true;
613  case 0x1b: HandlePacketCraftingBookData(a_ByteBuffer); return true;
614  case 0x1c: HandlePacketNameItem(a_ByteBuffer); return true;
615  case 0x1d: break; // Resource pack status - not yet implemented
616  case 0x1e: HandlePacketAdvancementTab(a_ByteBuffer); return true;
617  case 0x20: HandlePacketSetBeaconEffect(a_ByteBuffer); return true;
618  case 0x21: HandlePacketSlotSelect(a_ByteBuffer); return true;
619  case 0x24: HandlePacketCreativeInventoryAction(a_ByteBuffer); return true;
620  case 0x26: HandlePacketUpdateSign(a_ByteBuffer); return true;
621  case 0x27: HandlePacketAnimation(a_ByteBuffer); return true;
622  case 0x28: HandlePacketSpectate(a_ByteBuffer); return true;
623  case 0x29: HandlePacketBlockPlace(a_ByteBuffer); return true;
624  case 0x2a: HandlePacketUseItem(a_ByteBuffer); return true;
625  }
626 
627  return Super::HandlePacket(a_ByteBuffer, a_PacketType);
628 }
629 
630 
631 
632 
633 
635 {
636  HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, NewItemName);
637 
638  LOGD("New item name : %s", NewItemName);
639 }
640 
641 
642 
643 
644 
646 {
647  HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, NamespacedChannel);
648 
649  const auto & [Namespace, Channel] = NamespaceSerializer::SplitNamespacedID(NamespacedChannel);
650 
651  // If the plugin channel is recognized vanilla, handle it directly:
653  {
654  HandleVanillaPluginMessage(a_ByteBuffer, Channel);
655  return;
656  }
657 
659 
660  // Read the plugin message and relay to clienthandle:
661  a_ByteBuffer.ReadSome(Data, a_ByteBuffer.GetReadableSpace());
662  m_Client->HandlePluginMessage(NamespacedChannel, Data);
663 }
664 
665 
666 
667 
668 
670 {
671  HANDLE_READ(a_ByteBuffer, ReadVarInt32, UInt32, Effect1);
672  HANDLE_READ(a_ByteBuffer, ReadVarInt32, UInt32, Effect2);
673  m_Client->HandleBeaconSelection(Effect1, Effect2);
674 }
675 
676 
677 
678 
679 
680 void cProtocol_1_13::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const std::string_view a_Channel)
681 {
682  if (a_Channel == "brand")
683  {
684  HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Brand);
685 
686  m_Client->SetClientBrand(Brand);
687  m_Client->SendPluginMessage("brand", "\x08""Cuberite"); // Send back our brand, including the length.
688  }
689 }
690 
691 
692 
693 
694 
695 bool cProtocol_1_13::ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item, size_t a_KeepRemainingBytes) const
696 {
697  HANDLE_PACKET_READ(a_ByteBuffer, ReadBEInt16, Int16, ItemID);
698  if (ItemID == -1)
699  {
700  // The item is empty, no more data follows
701  a_Item.Empty();
702  return true;
703  }
704 
705  const auto Translated = GetItemFromProtocolID(ToUnsigned(ItemID));
706  a_Item.m_ItemType = Translated.first;
707  a_Item.m_ItemDamage = Translated.second;
708 
709  HANDLE_PACKET_READ(a_ByteBuffer, ReadBEInt8, Int8, ItemCount);
710  a_Item.m_ItemCount = ItemCount;
711  if (ItemCount <= 0)
712  {
713  a_Item.Empty();
714  }
715 
717  if (!a_ByteBuffer.ReadSome(Metadata, a_ByteBuffer.GetReadableSpace() - a_KeepRemainingBytes) || Metadata.empty() || (Metadata[0] == std::byte(0)))
718  {
719  // No metadata
720  return true;
721  }
722 
723  ParseItemMetadata(a_Item, Metadata);
724  return true;
725 }
726 
727 
728 
729 
730 
731 void cProtocol_1_13::WriteEntityMetadata(cPacketizer & a_Pkt, const EntityMetadata a_Metadata, const EntityMetadataType a_FieldType) const
732 {
733  a_Pkt.WriteBEUInt8(GetEntityMetadataID(a_Metadata)); // Index
734  a_Pkt.WriteBEUInt8(GetEntityMetadataID(a_FieldType)); // Type
735 }
736 
737 
738 
739 
740 
741 void cProtocol_1_13::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_Entity) const
742 {
743  // Common metadata:
744  Int8 Flags = 0;
745  if (a_Entity.IsOnFire())
746  {
747  Flags |= 0x01;
748  }
749  if (a_Entity.IsCrouched())
750  {
751  Flags |= 0x02;
752  }
753  if (a_Entity.IsSprinting())
754  {
755  Flags |= 0x08;
756  }
757  if (a_Entity.IsRclking())
758  {
759  Flags |= 0x10;
760  }
761  if (a_Entity.IsInvisible())
762  {
763  Flags |= 0x20;
764  }
765 
767  a_Pkt.WriteBEInt8(Flags);
768 
769  switch (a_Entity.GetEntityType())
770  {
771  case cEntity::etPlayer:
772  {
773  auto & Player = static_cast<const cPlayer &>(a_Entity);
774 
775  // TODO Set player custom name to their name.
776  // Then it's possible to move the custom name of mobs to the entities
777  // and to remove the "special" player custom name.
779  a_Pkt.WriteString(Player.GetName());
780 
782  a_Pkt.WriteBEFloat(static_cast<float>(Player.GetHealth()));
783 
785  a_Pkt.WriteBEUInt8(static_cast<UInt8>(Player.GetSkinParts()));
786 
788  a_Pkt.WriteBEUInt8(Player.IsLeftHanded() ? 0 : 1);
789  break;
790  }
791  case cEntity::etPickup:
792  {
794  WriteItem(a_Pkt, static_cast<const cPickup &>(a_Entity).GetItem());
795  break;
796  }
797  case cEntity::etMinecart:
798  {
800 
801  // The following expression makes Minecarts shake more with less health or higher damage taken
802  auto & Minecart = static_cast<const cMinecart &>(a_Entity);
803  auto maxHealth = a_Entity.GetMaxHealth();
804  auto curHealth = a_Entity.GetHealth();
805  a_Pkt.WriteVarInt32(static_cast<UInt32>((maxHealth - curHealth) * Minecart.LastDamage() * 4));
806 
808  a_Pkt.WriteVarInt32(1); // (doesn't seem to effect anything)
809 
811  a_Pkt.WriteBEFloat(static_cast<float>(Minecart.LastDamage() + 10)); // or damage taken
812 
813  if (Minecart.GetPayload() == cMinecart::mpNone)
814  {
815  auto & RideableMinecart = static_cast<const cRideableMinecart &>(Minecart);
816  const cItem & MinecartContent = RideableMinecart.GetContent();
817  if (!MinecartContent.IsEmpty())
818  {
820  int Content = MinecartContent.m_ItemType;
821  Content |= MinecartContent.m_ItemDamage << 8;
822  a_Pkt.WriteVarInt32(static_cast<UInt32>(Content));
823 
825  a_Pkt.WriteVarInt32(static_cast<UInt32>(RideableMinecart.GetBlockHeight()));
826 
828  a_Pkt.WriteBool(true);
829  }
830  }
831  else if (Minecart.GetPayload() == cMinecart::mpFurnace)
832  {
834  a_Pkt.WriteBool(static_cast<const cMinecartWithFurnace &>(Minecart).IsFueled());
835  }
836  break;
837  } // case etMinecart
838 
840  {
841  auto & Projectile = static_cast<const cProjectileEntity &>(a_Entity);
842  switch (Projectile.GetProjectileKind())
843  {
845  {
847  a_Pkt.WriteBEInt8(static_cast<const cArrowEntity &>(Projectile).IsCritical() ? 1 : 0);
848  break;
849  }
851  {
852  // TODO
853  break;
854  }
856  {
857  // TODO
858  }
859  default:
860  {
861  break;
862  }
863  }
864  break;
865  } // case etProjectile
866 
867  case cEntity::etMonster:
868  {
869  WriteMobMetadata(a_Pkt, static_cast<const cMonster &>(a_Entity));
870  break;
871  }
872 
873  case cEntity::etBoat:
874  {
875  auto & Boat = static_cast<const cBoat &>(a_Entity);
876 
878  a_Pkt.WriteVarInt32(static_cast<UInt32>(Boat.GetLastDamage()));
879 
881  a_Pkt.WriteVarInt32(static_cast<UInt32>(Boat.GetForwardDirection()));
882 
884  a_Pkt.WriteBEFloat(Boat.GetDamageTaken());
885 
887  a_Pkt.WriteVarInt32(static_cast<UInt32>(Boat.GetMaterial()));
888 
890  a_Pkt.WriteBool(Boat.IsRightPaddleUsed());
891 
893  a_Pkt.WriteBool(static_cast<bool>(Boat.IsLeftPaddleUsed()));
894 
896  a_Pkt.WriteVarInt32(0);
897 
898  break;
899  } // case etBoat
900 
902  {
903  const auto & Frame = static_cast<const cItemFrame &>(a_Entity);
905  WriteItem(a_Pkt, Frame.GetItem());
907  a_Pkt.WriteVarInt32(Frame.GetItemRotation());
908  break;
909  } // case etItemFrame
910 
912  {
913  const auto & EnderCrystal = static_cast<const cEnderCrystal &>(a_Entity);
914  if (EnderCrystal.DisplaysBeam())
915  {
917  a_Pkt.WriteBool(true); // Dont do a second check if it should display the beam
918  a_Pkt.WriteXYZPosition64(EnderCrystal.GetBeamTarget());
919  }
921  a_Pkt.WriteBool(EnderCrystal.ShowsBottom());
922  break;
923  } // case etEnderCrystal
924 
925  default:
926  {
927  break;
928  }
929  }
930 }
931 
932 
933 
934 
935 
936 void cProtocol_1_13::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item) const
937 {
938  short ItemType = a_Item.m_ItemType;
939  ASSERT(ItemType >= -1); // Check validity of packets in debug runtime
940  if (ItemType <= 0)
941  {
942  // Fix, to make sure no invalid values are sent.
943  ItemType = -1;
944  }
945 
946  if (a_Item.IsEmpty())
947  {
948  a_Pkt.WriteBEInt16(-1);
949  return;
950  }
951 
952  // Normal item
953  a_Pkt.WriteBEInt16(static_cast<Int16>(GetProtocolItemType(a_Item.m_ItemType, a_Item.m_ItemDamage)));
954  a_Pkt.WriteBEInt8(a_Item.m_ItemCount);
955 
956  // TODO: NBT
957  a_Pkt.WriteBEInt8(0);
958 }
959 
960 
961 
962 
963 
964 void cProtocol_1_13::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) const
965 {
966  // Living Enitiy Metadata
967  if (a_Mob.HasCustomName())
968  {
969  // TODO: As of 1.9 _all_ entities can have custom names; should this be moved up?
971  a_Pkt.WriteBool(true);
972  a_Pkt.WriteString(a_Mob.GetCustomName());
973 
975  a_Pkt.WriteBool(a_Mob.IsCustomNameAlwaysVisible());
976  }
977 
979  a_Pkt.WriteBEFloat(static_cast<float>(a_Mob.GetHealth()));
980 
981  switch (a_Mob.GetMobType())
982  {
983  case mtBat:
984  {
985  auto & Bat = static_cast<const cBat &>(a_Mob);
986 
988  a_Pkt.WriteBEInt8(Bat.IsHanging() ? 1 : 0);
989  break;
990  } // case mtBat
991 
992  case mtChicken:
993  {
994  auto & Chicken = static_cast<const cChicken &>(a_Mob);
995 
997  a_Pkt.WriteBool(Chicken.IsBaby());
998  break;
999  } // case mtChicken
1000 
1001  case mtCow:
1002  {
1003  auto & Cow = static_cast<const cCow &>(a_Mob);
1004 
1006  a_Pkt.WriteBool(Cow.IsBaby());
1007  break;
1008  } // case mtCow
1009 
1010  case mtCreeper:
1011  {
1012  auto & Creeper = static_cast<const cCreeper &>(a_Mob);
1013 
1015  a_Pkt.WriteVarInt32(Creeper.IsBlowing() ? 1 : static_cast<UInt32>(-1)); // (idle or "blowing")
1016 
1018  a_Pkt.WriteBool(Creeper.IsCharged());
1019 
1021  a_Pkt.WriteBool(Creeper.IsBurnedWithFlintAndSteel());
1022  break;
1023  } // case mtCreeper
1024 
1025  case mtEnderman:
1026  {
1027  auto & Enderman = static_cast<const cEnderman &>(a_Mob);
1029  UInt32 Carried = 0;
1030  Carried |= static_cast<UInt32>(Enderman.GetCarriedBlock() << 4);
1031  Carried |= Enderman.GetCarriedMeta();
1032  a_Pkt.WriteVarInt32(Carried);
1033 
1035  a_Pkt.WriteBool(Enderman.IsScreaming());
1036  break;
1037  } // case mtEnderman
1038 
1039  case mtGhast:
1040  {
1041  auto & Ghast = static_cast<const cGhast &>(a_Mob);
1042 
1044  a_Pkt.WriteBool(Ghast.IsCharging());
1045  break;
1046  } // case mtGhast
1047 
1048  case mtHorse:
1049  {
1050  // XXX This behaves incorrectly with different varients; horses have different entity IDs now
1051 
1052  // Abstract horse
1053  auto & Horse = static_cast<const cHorse &>(a_Mob);
1054 
1055  Int8 Flags = 0;
1056  if (Horse.IsTame())
1057  {
1058  Flags |= 0x02;
1059  }
1060  if (Horse.IsSaddled())
1061  {
1062  Flags |= 0x04;
1063  }
1064  if (Horse.IsInLoveCooldown())
1065  {
1066  Flags |= 0x08;
1067  }
1068  if (Horse.IsEating())
1069  {
1070  Flags |= 0x10;
1071  }
1072  if (Horse.IsRearing())
1073  {
1074  Flags |= 0x20;
1075  }
1076  if (Horse.IsMthOpen())
1077  {
1078  Flags |= 0x40;
1079  }
1081  a_Pkt.WriteBEInt8(Flags);
1082 
1083  // Regular horses
1084  int Appearance = 0;
1085  Appearance = Horse.GetHorseColor();
1086  Appearance |= Horse.GetHorseStyle() << 8;
1088  a_Pkt.WriteVarInt32(static_cast<UInt32>(Appearance)); // Color / style
1089 
1091  a_Pkt.WriteVarInt32(static_cast<UInt32>(Horse.GetHorseArmour()));
1092 
1094  a_Pkt.WriteBool(Horse.IsBaby());
1095  break;
1096  } // case mtHorse
1097 
1098  case mtMagmaCube:
1099  {
1100  auto & MagmaCube = static_cast<const cMagmaCube &>(a_Mob);
1101 
1103  a_Pkt.WriteVarInt32(static_cast<UInt32>(MagmaCube.GetSize()));
1104  break;
1105  } // case mtMagmaCube
1106 
1107  case mtOcelot:
1108  {
1109  auto & Ocelot = static_cast<const cOcelot &>(a_Mob);
1110 
1112  a_Pkt.WriteBool(Ocelot.IsBaby());
1113 
1114  Int8 OcelotStatus = 0;
1115  if (Ocelot.IsSitting())
1116  {
1117  OcelotStatus |= 0x1;
1118  }
1119  if (Ocelot.IsTame())
1120  {
1121  OcelotStatus |= 0x4;
1122  }
1124  a_Pkt.WriteBEInt8(OcelotStatus);
1125 
1127  a_Pkt.WriteVarInt32(static_cast<UInt32>(Ocelot.GetOcelotType()));
1128 
1129  break;
1130  } // case mtOcelot
1131 
1132  case mtPig:
1133  {
1134  auto & Pig = static_cast<const cPig &>(a_Mob);
1135 
1137  a_Pkt.WriteBool(Pig.IsBaby());
1138 
1140  a_Pkt.WriteBool(Pig.IsSaddled());
1141 
1142  // PIG_TOTAL_CARROT_ON_A_STICK_BOOST in 1.11.1 only
1143  break;
1144  } // case mtPig
1145 
1146  case mtRabbit:
1147  {
1148  auto & Rabbit = static_cast<const cRabbit &>(a_Mob);
1149 
1151  a_Pkt.WriteBool(Rabbit.IsBaby());
1152 
1154  a_Pkt.WriteVarInt32(static_cast<UInt32>(Rabbit.GetRabbitType()));
1155  break;
1156  } // case mtRabbit
1157 
1158  case mtSheep:
1159  {
1160  auto & Sheep = static_cast<const cSheep &>(a_Mob);
1161 
1163  a_Pkt.WriteBool(Sheep.IsBaby());
1164 
1165  Int8 SheepMetadata = 0;
1166  SheepMetadata = static_cast<Int8>(Sheep.GetFurColor());
1167  if (Sheep.IsSheared())
1168  {
1169  SheepMetadata |= 0x10;
1170  }
1172  a_Pkt.WriteBEInt8(SheepMetadata);
1173  break;
1174  } // case mtSheep
1175 
1176  case mtSkeleton:
1177  {
1178  auto & Skeleton = static_cast<const cSkeleton &>(a_Mob);
1180  a_Pkt.WriteBEUInt8(Skeleton.IsChargingBow() ? 0x01 : 0x00);
1181 
1183  a_Pkt.WriteBool(Skeleton.IsChargingBow());
1184  break;
1185  } // case mtSkeleton
1186 
1187  case mtSlime:
1188  {
1189  auto & Slime = static_cast<const cSlime &>(a_Mob);
1190 
1192  a_Pkt.WriteVarInt32(static_cast<UInt32>(Slime.GetSize()));
1193  break;
1194  } // case mtSlime
1195 
1196  case mtVillager:
1197  {
1198  auto & Villager = static_cast<const cVillager &>(a_Mob);
1199 
1201  a_Pkt.WriteBool(Villager.IsBaby());
1202 
1204  a_Pkt.WriteVarInt32(static_cast<UInt32>(Villager.GetVilType()));
1205  break;
1206  } // case mtVillager
1207 
1208  case mtWitch:
1209  {
1210  auto & Witch = static_cast<const cWitch &>(a_Mob);
1211 
1213  a_Pkt.WriteBool(Witch.IsAngry());
1214  break;
1215  } // case mtWitch
1216 
1217  case mtWither:
1218  {
1219  auto & Wither = static_cast<const cWither &>(a_Mob);
1220 
1222  a_Pkt.WriteVarInt32(Wither.GetWitherInvulnerableTicks());
1223 
1224  // TODO: Use boss bar packet for health
1225  break;
1226  } // case mtWither
1227 
1228  case mtWolf:
1229  {
1230  auto & Wolf = static_cast<const cWolf &>(a_Mob);
1231 
1233  a_Pkt.WriteBool(Wolf.IsBaby());
1234 
1235  Int8 WolfStatus = 0;
1236  if (Wolf.IsSitting())
1237  {
1238  WolfStatus |= 0x1;
1239  }
1240  if (Wolf.IsAngry())
1241  {
1242  WolfStatus |= 0x2;
1243  }
1244  if (Wolf.IsTame())
1245  {
1246  WolfStatus |= 0x4;
1247  }
1249  a_Pkt.WriteBEInt8(WolfStatus);
1250 
1252  a_Pkt.WriteBEFloat(static_cast<float>(a_Mob.GetHealth())); // TODO Not use the current health
1253 
1255  a_Pkt.WriteBool(Wolf.IsBegging());
1256 
1258  a_Pkt.WriteVarInt32(static_cast<UInt32>(Wolf.GetCollarColor()));
1259  break;
1260  } // case mtWolf
1261 
1262  case mtZombie:
1263  {
1264  // XXX Zombies were also split into new sublcasses; this doesn't handle that.
1265 
1266  auto & Zombie = static_cast<const cZombie &>(a_Mob);
1267 
1269  a_Pkt.WriteBool(Zombie.IsBaby());
1270  break;
1271  } // case mtZombie
1272 
1273  case mtZombiePigman:
1274  {
1275  auto & ZombiePigman = static_cast<const cZombiePigman &>(a_Mob);
1276 
1278  a_Pkt.WriteBool(ZombiePigman.IsBaby());
1279  break;
1280  } // case mtZombiePigman
1281 
1282  case mtBlaze:
1283  case mtEnderDragon:
1284  case mtIronGolem:
1285  case mtSnowGolem:
1286  case mtSpider:
1287  case mtZombieVillager:
1288 
1289  case mtElderGuardian:
1290  case mtGuardian:
1291  {
1292  // TODO: Mobs with extra fields that aren't implemented
1293  break;
1294  }
1295 
1296  case mtCat:
1297 
1298  case mtCod:
1299 
1300  case mtDolphin:
1301 
1302  case mtDonkey:
1303 
1304  case mtDrowned:
1305 
1306  case mtEvoker:
1307 
1308  case mtIllusioner:
1309 
1310  case mtLlama:
1311 
1312  case mtMule:
1313 
1314  case mtParrot:
1315 
1316  case mtPhantom:
1317 
1318  case mtPolarBear:
1319 
1320  case mtPufferfish:
1321 
1322  case mtSalmon:
1323 
1324  case mtShulker:
1325 
1326  case mtStray:
1327 
1328  case mtSkeletonHorse:
1329  case mtZombieHorse:
1330 
1331  case mtTropicalFish:
1332 
1333  case mtTurtle:
1334 
1335  case mtVex:
1336 
1337  case mtVindicator:
1338 
1339  case mtHusk:
1340  {
1341  // Todo: Mobs not added yet. Grouped ones have the same metadata
1342  ASSERT(!"cProtocol_1_13::WriteMobMetadata: received unimplemented type");
1343  break;
1344  }
1345 
1346  case mtMooshroom:
1347  case mtCaveSpider:
1348  {
1349  // Not mentioned on http://wiki.vg/Entities
1350  break;
1351  }
1352 
1353  case mtEndermite:
1354  case mtGiant:
1355  case mtSilverfish:
1356  case mtSquid:
1357  case mtWitherSkeleton:
1358  {
1359  // Mobs with no extra fields
1360  break;
1361  }
1362 
1363  default: UNREACHABLE("cProtocol_1_13::WriteMobMetadata: received mob of invalid type");
1364  } // switch (a_Mob.GetType())
1365 }
1366 
1367 
1368 
1369 
1370 
1372 // cProtocol_1_13_1:
1373 
1374 void cProtocol_1_13_1::SendBossBarAdd(UInt32 a_UniqueID, const cCompositeChat & a_Title, float a_FractionFilled, BossBarColor a_Color, BossBarDivisionType a_DivisionType, bool a_DarkenSky, bool a_PlayEndMusic, bool a_CreateFog)
1375 {
1376  ASSERT(m_State == 3); // In game mode?
1377 
1378  cPacketizer Pkt(*this, pktBossBar);
1379  // TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now.
1380  Pkt.WriteBEUInt64(0);
1381  Pkt.WriteBEUInt64(a_UniqueID);
1382  Pkt.WriteVarInt32(0); // Add
1383  Pkt.WriteString(a_Title.CreateJsonString());
1384  Pkt.WriteBEFloat(a_FractionFilled);
1385  Pkt.WriteVarInt32([a_Color]
1386  {
1387  switch (a_Color)
1388  {
1389  case BossBarColor::Pink: return 0U;
1390  case BossBarColor::Blue: return 1U;
1391  case BossBarColor::Red: return 2U;
1392  case BossBarColor::Green: return 3U;
1393  case BossBarColor::Yellow: return 4U;
1394  case BossBarColor::Purple: return 5U;
1395  case BossBarColor::White: return 6U;
1396  }
1397  UNREACHABLE("Unsupported boss bar property");
1398  }());
1399  Pkt.WriteVarInt32([a_DivisionType]
1400  {
1401  switch (a_DivisionType)
1402  {
1403  case BossBarDivisionType::None: return 0U;
1404  case BossBarDivisionType::SixNotches: return 1U;
1405  case BossBarDivisionType::TenNotches: return 2U;
1406  case BossBarDivisionType::TwelveNotches: return 3U;
1407  case BossBarDivisionType::TwentyNotches: return 4U;
1408  }
1409  UNREACHABLE("Unsupported boss bar property");
1410  }());
1411  {
1412  UInt8 Flags = 0x00;
1413  if (a_DarkenSky)
1414  {
1415  Flags |= 0x01;
1416  }
1417  if (a_PlayEndMusic)
1418  {
1419  Flags |= 0x02;
1420  }
1421  if (a_CreateFog)
1422  {
1423  Flags |= 0x04; // Only difference to 1.9 is fog now a separate flag
1424  }
1425  Pkt.WriteBEUInt8(Flags);
1426  }
1427 }
1428 
1429 
1430 
1431 
1432 
1433 void cProtocol_1_13_1::SendBossBarUpdateFlags(UInt32 a_UniqueID, bool a_DarkenSky, bool a_PlayEndMusic, bool a_CreateFog)
1434 {
1435  ASSERT(m_State == 3); // In game mode?
1436 
1437  cPacketizer Pkt(*this, pktBossBar);
1438  // TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now.
1439  Pkt.WriteBEUInt64(0);
1440  Pkt.WriteBEUInt64(a_UniqueID);
1441  Pkt.WriteVarInt32(5); // Update Flags
1442  {
1443  UInt8 Flags = 0x00;
1444  if (a_DarkenSky)
1445  {
1446  Flags |= 0x01;
1447  }
1448  if (a_PlayEndMusic)
1449  {
1450  Flags |= 0x02;
1451  }
1452  if (a_CreateFog)
1453  {
1454  Flags |= 0x04; // Only difference to 1.9 is fog now a separate flag
1455  }
1456  Pkt.WriteBEUInt8(Flags);
1457  }
1458 }
1459 
1460 
1461 
1462 
1463 
1464 std::pair<short, short> cProtocol_1_13_1::GetItemFromProtocolID(UInt32 a_ProtocolID) const
1465 {
1466  return PaletteUpgrade::ToItem(Palette_1_13_1::ToItem(a_ProtocolID));
1467 }
1468 
1469 
1470 
1471 
1472 
1474 {
1475  return Palette_1_13_1::From(PaletteUpgrade::FromBlock(a_BlockType, a_Meta));
1476 }
1477 
1478 
1479 
1480 
1481 
1482 UInt32 cProtocol_1_13_1::GetProtocolItemType(short a_ItemID, short a_ItemDamage) const
1483 {
1484  return Palette_1_13_1::From(PaletteUpgrade::FromItem(a_ItemID, a_ItemDamage));
1485 }
1486 
1487 
1488 
1489 
1490 
1492 {
1493  return Palette_1_13_1::From(a_Statistic);
1494 }
1495 
1496 
1497 
1498 
1499 
1501 {
1502  return Version::v1_13_1;
1503 }
1504 
1505 
1506 
1507 
1508 
1510 // cProtocol_1_13_2:
1511 
1513 {
1514  return Version::v1_13_2;
1515 }
1516 
1517 
1518 
1519 
1520 
1521 bool cProtocol_1_13_2::ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item, size_t a_KeepRemainingBytes) const
1522 {
1523  HANDLE_PACKET_READ(a_ByteBuffer, ReadBool, bool, Present);
1524  if (!Present)
1525  {
1526  // The item is empty, no more data follows
1527  a_Item.Empty();
1528  return true;
1529  }
1530 
1531  HANDLE_PACKET_READ(a_ByteBuffer, ReadVarInt32, UInt32, ItemID);
1532  const auto Translated = GetItemFromProtocolID(ItemID);
1533  a_Item.m_ItemType = Translated.first;
1534  a_Item.m_ItemDamage = Translated.second;
1535 
1536  HANDLE_PACKET_READ(a_ByteBuffer, ReadBEInt8, Int8, ItemCount);
1537  a_Item.m_ItemCount = ItemCount;
1538  if (ItemCount <= 0)
1539  {
1540  a_Item.Empty();
1541  }
1542 
1544  if (!a_ByteBuffer.ReadSome(Metadata, a_ByteBuffer.GetReadableSpace() - a_KeepRemainingBytes) || Metadata.empty() || (Metadata[0] == std::byte(0)))
1545  {
1546  // No metadata
1547  return true;
1548  }
1549 
1550  ParseItemMetadata(a_Item, Metadata);
1551  return true;
1552 }
1553 
1554 
1555 
1556 
1557 
1558 void cProtocol_1_13_2::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item) const
1559 {
1560  short ItemType = a_Item.m_ItemType;
1561  ASSERT(ItemType >= -1); // Check validity of packets in debug runtime
1562  if (ItemType <= 0)
1563  {
1564  // Fix, to make sure no invalid values are sent.
1565  ItemType = -1;
1566  }
1567 
1568  if (a_Item.IsEmpty())
1569  {
1570  a_Pkt.WriteBool(false);
1571  return;
1572  }
1573 
1574  // Item present
1575  a_Pkt.WriteBool(true);
1576 
1577  // Normal item
1579  a_Pkt.WriteBEInt8(a_Item.m_ItemCount);
1580 
1581  // TODO: NBT
1582  a_Pkt.WriteBEInt8(0);
1583 }
@ E_BLOCK_HEAD
Definition: BlockType.h:159
@ E_BLOCK_STANDING_BANNER
Definition: BlockType.h:195
@ E_BLOCK_ENCHANTMENT_TABLE
Definition: BlockType.h:131
@ E_BLOCK_SIGN_POST
Definition: BlockType.h:76
@ E_BLOCK_BEACON
Definition: BlockType.h:153
@ E_BLOCK_CHEST
Definition: BlockType.h:64
@ E_BLOCK_TRAPPED_CHEST
Definition: BlockType.h:161
@ E_BLOCK_COMMAND_BLOCK
Definition: BlockType.h:152
@ E_BLOCK_END_GATEWAY
Definition: BlockType.h:228
@ E_BLOCK_BED
Definition: BlockType.h:36
@ E_BLOCK_END_PORTAL
Definition: BlockType.h:134
@ E_BLOCK_MOB_SPAWNER
Definition: BlockType.h:62
@ E_BLOCK_WALL_BANNER
Definition: BlockType.h:196
std::vector< sSetBlock > sSetBlockVector
Definition: ChunkDef.h:441
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:44
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:41
BossBarDivisionType
Definition: Defines.h:443
EntityAnimation
Definition: Defines.h:458
BossBarColor
Definition: Defines.h:428
#define UNREACHABLE(x)
Definition: Globals.h:288
auto ToUnsigned(T a_Val)
Definition: Globals.h:387
unsigned int UInt32
Definition: Globals.h:157
signed short Int16
Definition: Globals.h:153
signed char Int8
Definition: Globals.h:154
unsigned char UInt8
Definition: Globals.h:159
#define ASSERT(x)
Definition: Globals.h:276
std::basic_string< std::byte > ContiguousByteBuffer
Definition: Globals.h:375
unsigned char Byte
Definition: Globals.h:161
#define LOGD
Definition: LoggerSimple.h:83
eMonsterType
Identifies individual monster type.
Definition: MonsterTypes.h:11
@ mtZombieVillager
Definition: MonsterTypes.h:82
@ mtVindicator
Definition: MonsterTypes.h:72
@ mtElderGuardian
Definition: MonsterTypes.h:25
@ mtSkeleton
Definition: MonsterTypes.h:59
@ mtSheep
Definition: MonsterTypes.h:56
@ mtEndermite
Definition: MonsterTypes.h:28
@ mtTurtle
Definition: MonsterTypes.h:69
@ mtPolarBear
Definition: MonsterTypes.h:51
@ mtDolphin
Definition: MonsterTypes.h:22
@ mtMagmaCube
Definition: MonsterTypes.h:40
@ mtWolf
Definition: MonsterTypes.h:77
@ mtStray
Definition: MonsterTypes.h:65
@ mtRabbit
Definition: MonsterTypes.h:53
@ mtCat
Definition: MonsterTypes.h:16
@ mtZombie
Definition: MonsterTypes.h:79
@ mtOcelot
Definition: MonsterTypes.h:43
@ mtDonkey
Definition: MonsterTypes.h:23
@ mtVex
Definition: MonsterTypes.h:70
@ mtEnderman
Definition: MonsterTypes.h:27
@ mtTropicalFish
Definition: MonsterTypes.h:68
@ mtHusk
Definition: MonsterTypes.h:36
@ mtCaveSpider
Definition: MonsterTypes.h:17
@ mtEvoker
Definition: MonsterTypes.h:29
@ mtPhantom
Definition: MonsterTypes.h:46
@ mtShulker
Definition: MonsterTypes.h:57
@ mtPufferfish
Definition: MonsterTypes.h:52
@ mtWither
Definition: MonsterTypes.h:75
@ mtSkeletonHorse
Definition: MonsterTypes.h:60
@ mtPig
Definition: MonsterTypes.h:47
@ mtDrowned
Definition: MonsterTypes.h:24
@ mtVillager
Definition: MonsterTypes.h:71
@ mtHorse
Definition: MonsterTypes.h:34
@ mtZombieHorse
Definition: MonsterTypes.h:80
@ mtWitch
Definition: MonsterTypes.h:74
@ mtCow
Definition: MonsterTypes.h:20
@ mtSalmon
Definition: MonsterTypes.h:55
@ mtEnderDragon
Definition: MonsterTypes.h:26
@ mtMooshroom
Definition: MonsterTypes.h:41
@ mtSquid
Definition: MonsterTypes.h:64
@ mtInvalidType
Definition: MonsterTypes.h:12
@ mtBat
Definition: MonsterTypes.h:14
@ mtIllusioner
Definition: MonsterTypes.h:37
@ mtChicken
Definition: MonsterTypes.h:18
@ mtGiant
Definition: MonsterTypes.h:32
@ mtSnowGolem
Definition: MonsterTypes.h:62
@ mtBlaze
Definition: MonsterTypes.h:15
@ mtLlama
Definition: MonsterTypes.h:39
@ mtIronGolem
Definition: MonsterTypes.h:38
@ mtCreeper
Definition: MonsterTypes.h:21
@ mtSpider
Definition: MonsterTypes.h:63
@ mtMule
Definition: MonsterTypes.h:42
@ mtGhast
Definition: MonsterTypes.h:31
@ mtParrot
Definition: MonsterTypes.h:45
@ mtSilverfish
Definition: MonsterTypes.h:58
@ mtCod
Definition: MonsterTypes.h:19
@ mtZombiePigman
Definition: MonsterTypes.h:85
@ mtSlime
Definition: MonsterTypes.h:61
@ mtWitherSkeleton
Definition: MonsterTypes.h:76
@ mtGuardian
Definition: MonsterTypes.h:33
#define HANDLE_PACKET_READ(ByteBuf, Proc, Type, Var)
Definition: Packetizer.h:41
#define HANDLE_READ(ByteBuf, Proc, Type, Var)
Macros used to read packets more easily.
Definition: Packetizer.h:28
CustomStatistic
@ Rabbit
@ Chicken
@ Minecart
std::vector< AString > AStringVector
Definition: StringUtils.h:12
std::string AString
Definition: StringUtils.h:11
UInt32 From(const BlockState Block)
Definition: Palette_1_13.cpp:7
Item ToItem(const UInt32 ID)
Item ToItem(const UInt32 ID)
UInt32 From(const BlockState Block)
Item FromItem(const short Item, const short Damage)
Definition: Upgrade.cpp:1708
std::pair< short, short > ToItem(const Item ID)
Definition: Upgrade.cpp:2519
BlockState FromBlock(const BLOCKTYPE Block, const NIBBLETYPE Meta)
Definition: Upgrade.cpp:8
std::pair< Namespace, std::string_view > SplitNamespacedID(std::string_view ID)
int GetPosZ() const
Definition: BlockEntity.h:93
int GetPosY() const
Definition: BlockEntity.h:92
int GetPosX() const
Definition: BlockEntity.h:91
BLOCKTYPE GetBlockType() const
Definition: BlockEntity.h:97
An object that can store incoming bytes and lets its clients read the bytes sequentially The bytes ar...
Definition: ByteBuffer.h:32
size_t GetReadableSpace(void) const
Returns the number of bytes that are currently available for reading (may be less than UsedSpace due ...
Definition: ByteBuffer.cpp:198
bool ReadSome(ContiguousByteBuffer &a_String, size_t a_Count)
Reads a_Count bytes into a_String; returns true if successful.
Definition: ByteBuffer.cpp:927
void SetClientBrand(const AString &a_ClientBrand)
Called by the protocol when it receives the MC|Brand plugin message.
Definition: ClientHandle.h:276
void SendPluginMessage(const AString &a_Channel, std::string_view a_Message)
void HandlePluginMessage(const AString &a_Channel, ContiguousByteBufferView a_Message)
void HandleBeaconSelection(unsigned a_PrimaryEffect, unsigned a_SecondaryEffect)
Called when the protocol receives a MC|Beacon plugin message, indicating that the player set an effec...
Container for a single chat message composed of multiple functional parts.
Definition: CompositeChat.h:34
AString CreateJsonString(bool a_ShouldUseChatPrefixes=true) const
Definition: Boat.h:20
Definition: Entity.h:76
virtual bool IsRclking(void) const
Definition: Entity.h:490
virtual bool IsCrouched(void) const
Definition: Entity.h:486
float GetMaxHealth(void) const
Definition: Entity.h:407
eEntityType GetEntityType(void) const
Definition: Entity.h:156
virtual bool IsOnFire(void) const
Definition: Entity.h:489
virtual bool IsInvisible(void) const
Definition: Entity.h:488
float GetHealth(void) const
Returns the health of this entity.
Definition: Entity.h:367
@ etPickup
Definition: Entity.h:93
@ etProjectile
Definition: Entity.h:99
@ etItemFrame
Definition: Entity.h:102
@ etMinecart
Definition: Entity.h:96
@ etEnderCrystal
Definition: Entity.h:91
@ etMonster
Definition: Entity.h:94
@ etBoat
Definition: Entity.h:97
@ etPlayer
Definition: Entity.h:92
virtual bool IsSprinting(void) const
Definition: Entity.h:492
@ mpNone
Definition: Minecart.h:31
@ mpFurnace
Definition: Minecart.h:33
Definition: Pickup.h:20
Definition: Player.h:29
Definition: Item.h:37
char m_ItemCount
Definition: Item.h:164
bool IsEmpty(void) const
Returns true if the item represents an empty stack - either the type is invalid, or count is zero.
Definition: Item.h:69
short m_ItemType
Definition: Item.h:163
void Empty(void)
Empties the item and frees up any dynamic storage used by the internals.
Definition: Item.cpp:63
short m_ItemDamage
Definition: Item.h:165
Encapsulates an in-game world map.
Definition: Map.h:83
Definition: Bat.h:12
Definition: Cow.h:12
Definition: Ghast.h:12
Definition: Horse.h:14
bool HasCustomName(void) const
Returns true if the monster has a custom name.
Definition: Monster.h:165
const AString & GetCustomName(void) const
Gets the custom name of the monster.
Definition: Monster.h:168
bool IsCustomNameAlwaysVisible(void) const
Is the custom name of this monster always visible? If not, you only see the name when you sight the m...
Definition: Monster.h:175
eMonsterType GetMobType(void) const
Definition: Monster.h:70
Definition: Ocelot.h:13
Definition: Pig.h:12
Definition: Rabbit.h:27
Definition: Sheep.h:12
Definition: Slime.h:12
Definition: Witch.h:12
Definition: Wither.h:12
Definition: Wolf.h:14
Definition: Zombie.h:11
Composes an individual packet in the protocol's m_OutPacketBuffer; sends it just before being destruc...
Definition: Packetizer.h:60
void WriteVarInt32(UInt32 a_Value)
Definition: Packetizer.h:141
void WriteBEInt32(Int32 a_Value)
Definition: Packetizer.h:105
void WriteBool(bool a_Value)
Definition: Packetizer.h:76
void WriteXYZPosition64(int a_BlockX, int a_BlockY, int a_BlockZ)
Writes the specified block position as a single encoded 64-bit BigEndian integer.
Definition: Packetizer.h:161
void WriteBEUInt64(UInt64 a_Value)
Definition: Packetizer.h:123
void WriteBEFloat(float a_Value)
Definition: Packetizer.h:129
void WriteBEInt16(Int16 a_Value)
Definition: Packetizer.h:93
void WriteString(const AString &a_Value)
Definition: Packetizer.h:147
void WriteBEUInt8(UInt8 a_Value)
Definition: Packetizer.h:81
void WriteBuf(const ContiguousByteBufferView a_Data)
Definition: Packetizer.h:153
void WriteBEInt8(Int8 a_Value)
Definition: Packetizer.h:87
EntityMetadataType
Definition: Protocol.h:311
ePacketType
Logical types of outgoing packets.
Definition: Protocol.h:57
@ pktUnloadChunk
Definition: Protocol.h:123
@ pktEntityHeadLook
Definition: Protocol.h:77
@ pktSoundEffect
Definition: Protocol.h:108
@ pktEntityRelMove
Definition: Protocol.h:81
@ pktSoundParticleEffect
Definition: Protocol.h:109
@ pktEntityVelocity
Definition: Protocol.h:84
@ pktEntityMeta
Definition: Protocol.h:79
@ pktAttachEntity
Definition: Protocol.h:58
@ pktBlockChanges
Definition: Protocol.h:62
@ pktChatRaw
Definition: Protocol.h:65
@ pktUseBed
Definition: Protocol.h:129
@ pktMapData
Definition: Protocol.h:95
@ pktKeepAlive
Definition: Protocol.h:92
@ pktInventorySlot
Definition: Protocol.h:90
@ pktParticleEffect
Definition: Protocol.h:96
@ pktCameraSetTo
Definition: Protocol.h:64
@ pktEntityEffect
Definition: Protocol.h:75
@ pktTeleportEntity
Definition: Protocol.h:120
@ pktUpdateBlockEntity
Definition: Protocol.h:125
@ pktPluginMessage
Definition: Protocol.h:102
@ pktPlayerMoveLook
Definition: Protocol.h:101
@ pktEditSign
Definition: Protocol.h:72
@ pktStatistics
Definition: Protocol.h:117
@ pktSpawnPosition
Definition: Protocol.h:115
@ pktTimeUpdate
Definition: Protocol.h:121
@ pktBossBar
Definition: Protocol.h:63
@ pktPlayerList
Definition: Protocol.h:99
@ pktEntityRelMoveLook
Definition: Protocol.h:82
@ pktJoinGame
Definition: Protocol.h:91
@ pktExplosion
Definition: Protocol.h:86
@ pktDestroyEntity
Definition: Protocol.h:67
@ pktUpdateHealth
Definition: Protocol.h:126
@ pktUpdateScore
Definition: Protocol.h:127
@ pktEntityEquipment
Definition: Protocol.h:76
@ pktWindowOpen
Definition: Protocol.h:133
@ pktUpdateSign
Definition: Protocol.h:128
@ pktRespawn
Definition: Protocol.h:105
@ pktWindowProperty
Definition: Protocol.h:134
@ pktEntityProperties
Definition: Protocol.h:80
@ pktEntityStatus
Definition: Protocol.h:83
@ pktScoreboardObjective
Definition: Protocol.h:106
@ pktCollectEntity
Definition: Protocol.h:66
@ pktBlockChange
Definition: Protocol.h:61
@ pktRemoveEntityEffect
Definition: Protocol.h:103
@ pktUnlockRecipe
Definition: Protocol.h:124
@ pktTabCompletionResults
Definition: Protocol.h:119
@ pktHeldItemChange
Definition: Protocol.h:88
@ pktWindowClose
Definition: Protocol.h:132
@ pktPlayerListHeaderFooter
Definition: Protocol.h:100
@ pktEntityLook
Definition: Protocol.h:78
@ pktDisconnectDuringGame
Definition: Protocol.h:70
@ pktTitle
Definition: Protocol.h:122
@ pktPlayerAbilities
Definition: Protocol.h:98
@ pktWeather
Definition: Protocol.h:130
@ pktExperience
Definition: Protocol.h:85
@ pktGameMode
Definition: Protocol.h:87
@ pktLeashEntity
Definition: Protocol.h:93
@ pktWindowItems
Definition: Protocol.h:131
Version
The protocol version number, received from the client in the Handshake packet.
Definition: Protocol.h:335
EntityMetadata
Definition: Protocol.h:138
cClientHandle * m_Client
Definition: Protocol.h:472
virtual void WriteBlockEntity(cFastNBTWriter &a_Writer, const cBlockEntity &a_BlockEntity) const override
Writes the block entity data for the specified block entity into the packet.
virtual void HandlePacketBlockPlace(cByteBuffer &a_ByteBuffer) override
virtual void HandlePacketAdvancementTab(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketCraftingBookData(cByteBuffer &a_ByteBuffer)
virtual signed char GetProtocolEntityStatus(EntityAnimation a_Animation) const override
Converts an animation into an ID suitable for use with the Entity Status packet.
virtual bool HandlePacket(cByteBuffer &a_ByteBuffer, UInt32 a_PacketType) override
Reads and handles the packet.
virtual UInt32 GetPacketID(ePacketType a_Packet) const override
Get the packet ID for a given packet.
virtual void HandlePacketKeepAlive(cByteBuffer &a_ByteBuffer) override
virtual void WriteItem(cPacketizer &a_Pkt, const cItem &a_Item) const override
Writes the item data into a packet.
virtual std::pair< short, short > GetItemFromProtocolID(UInt32 a_ProtocolID) const
virtual void SendUpdateBlockEntity(cBlockEntity &a_BlockEntity) override
virtual Version GetProtocolVersion() const override
Returns the protocol version.
virtual void HandlePacketNameItem(cByteBuffer &a_ByteBuffer)
virtual void SendStatistics(const StatisticsManager &a_Manager) override
virtual UInt32 GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const
virtual void SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockVector &a_Changes) override
virtual void HandlePacketSetBeaconEffect(cByteBuffer &a_ByteBuffer)
virtual void WriteMobMetadata(cPacketizer &a_Pkt, const cMonster &a_Mob) const override
Writes the mob-specific metadata for the specified mob.
virtual void SendTabCompletionResults(const AStringVector &a_Results) override
virtual void SendPaintingSpawn(const cPainting &a_Painting) override
virtual void WriteEntityMetadata(cPacketizer &a_Pkt, EntityMetadata a_Metadata, EntityMetadataType a_FieldType) const
virtual bool ReadItem(cByteBuffer &a_ByteBuffer, cItem &a_Item, size_t a_KeepRemainingBytes) const override
Reads an item out of the received data, sets a_Item to the values read.
virtual bool HandlePacket(cByteBuffer &a_ByteBuffer, UInt32 a_PacketType) override
Reads and handles the packet.
virtual UInt8 GetEntityMetadataID(EntityMetadata a_Metadata) const
virtual void HandlePacketPluginMessage(cByteBuffer &a_ByteBuffer) override
virtual UInt32 GetProtocolItemType(short a_ItemID, short a_ItemDamage) const
virtual void SendParticleEffect(const AString &a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array< int, 2 > a_Data) override
virtual UInt32 GetProtocolStatisticType(CustomStatistic a_Statistic) const
virtual void SendMapData(const cMap &a_Map, int a_DataStartX, int a_DataStartY) override
virtual UInt32 GetProtocolMobType(eMonsterType a_MobType) const override
Converts eMonsterType to protocol-specific mob types.
virtual signed char GetProtocolEntityStatus(EntityAnimation a_Animation) const override
Converts an animation into an ID suitable for use with the Entity Status packet.
virtual void SendScoreboardObjective(const AString &a_Name, const AString &a_DisplayName, Byte a_Mode) override
virtual UInt32 GetPacketID(ePacketType a_PacketType) const override
Get the packet ID for a given packet.
virtual void SendBlockChange(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override
virtual void HandleVanillaPluginMessage(cByteBuffer &a_ByteBuffer, std::string_view a_Channel) override
Parses Vanilla plugin messages into specific ClientHandle calls.
virtual UInt32 GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
virtual UInt32 GetProtocolItemType(short a_ItemID, short a_ItemDamage) const override
virtual void SendBossBarUpdateFlags(UInt32 a_UniqueID, bool a_DarkenSky, bool a_PlayEndMusic, bool a_CreateFog) override
virtual void SendBossBarAdd(UInt32 a_UniqueID, const cCompositeChat &a_Title, float a_FractionFilled, BossBarColor a_Color, BossBarDivisionType a_DivisionType, bool a_DarkenSky, bool a_PlayEndMusic, bool a_CreateFog) override
virtual std::pair< short, short > GetItemFromProtocolID(UInt32 a_ProtocolID) const override
virtual UInt32 GetProtocolStatisticType(CustomStatistic a_Statistic) const override
virtual Version GetProtocolVersion() const override
Returns the protocol version.
virtual bool ReadItem(cByteBuffer &a_ByteBuffer, cItem &a_Item, size_t a_KeepRemainingBytes) const override
Reads an item out of the received data, sets a_Item to the values read.
virtual Version GetProtocolVersion() const override
Returns the protocol version.
virtual void WriteItem(cPacketizer &a_Pkt, const cItem &a_Item) const override
Writes the item data into a packet.
virtual void HandlePacketPlayer(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketEnchantItem(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketCreativeInventoryAction(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketWindowClose(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketPlayerAbilities(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketChatMessage(cByteBuffer &a_ByteBuffer)
State m_State
State of the protocol.
Definition: Protocol_1_8.h:143
virtual void HandlePacketPlayerLook(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketClientStatus(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketSlotSelect(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketSpectate(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketSteerVehicle(cByteBuffer &a_ByteBuffer) override
virtual void HandlePacketUseEntity(cByteBuffer &a_ByteBuffer) override
virtual void HandlePacketPlayerPos(cByteBuffer &a_ByteBuffer) override
virtual void HandlePacketUseItem(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketWindowClick(cByteBuffer &a_ByteBuffer) override
virtual void HandlePacketClientSettings(cByteBuffer &a_ByteBuffer) override
virtual void ParseItemMetadata(cItem &a_Item, ContiguousByteBufferView a_Metadata) const override
Parses item metadata as read by ReadItem(), into the item enchantments.
virtual void HandlePacketEntityAction(cByteBuffer &a_ByteBuffer) override
virtual void HandlePacketPlayerPosLook(cByteBuffer &a_ByteBuffer) override
virtual void HandlePacketBoatSteer(cByteBuffer &a_ByteBuffer)
virtual void HandleConfirmTeleport(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketUpdateSign(cByteBuffer &a_ByteBuffer) override
virtual void HandlePacketBlockDig(cByteBuffer &a_ByteBuffer) override
virtual void HandlePacketAnimation(cByteBuffer &a_ByteBuffer) override
virtual void HandlePacketVehicleMove(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketTabComplete(cByteBuffer &a_ByteBuffer) override
Class that manages the statistics and achievements of a single player.
std::unordered_map< CustomStatistic, StatValue > Custom
void Finish(void)
Definition: FastNBT.cpp:674
ContiguousByteBufferView GetResult(void) const
Definition: FastNBT.h:351