18 #include "../mbedTLS++/Sha1Checksum.h"
21 #include "../ClientHandle.h"
23 #include "../Server.h"
25 #include "../StringCompression.h"
26 #include "../CompositeChat.h"
27 #include "../JsonUtils.h"
29 #include "../WorldStorage/FastNBT.h"
31 #include "../Entities/EnderCrystal.h"
32 #include "../Entities/ExpOrb.h"
33 #include "../Entities/Minecart.h"
34 #include "../Entities/FallingBlock.h"
35 #include "../Entities/Painting.h"
36 #include "../Entities/Pickup.h"
37 #include "../Entities/Player.h"
38 #include "../Entities/ItemFrame.h"
39 #include "../Entities/ArrowEntity.h"
40 #include "../Entities/FireworkEntity.h"
41 #include "../Entities/SplashPotionEntity.h"
43 #include "../Items/ItemSpawnEgg.h"
45 #include "../Mobs/IncludeAllMonsters.h"
46 #include "../UI/HorseWindow.h"
48 #include "../BlockEntities/MobSpawnerEntity.h"
68 Super(a_Client, a_ServerAddress, a_State),
69 m_IsTeleportIdConfirmed(true),
70 m_OutstandingTeleportId(0)
118 switch (a_DivisionType)
134 if (a_PlayEndMusic || a_CreateFog)
176 if (a_PlayEndMusic || a_CreateFog)
229 switch (a_DivisionType)
314 Delta.HasNonZeroLength() &&
384 LOG(
"Trying to send a KeepAlive packet to a player who's not yet fully logged in (%d). The protocol class prevented the packet.",
m_State);
423 double PosX = a_Painting.
GetPosX();
424 double PosY = a_Painting.
GetPosY();
425 double PosZ = a_Painting.
GetPosZ();
453 Pkt.
WriteBEUInt8(
static_cast<Byte>((
static_cast<Int32>(Decorator.GetType()) << 4) | (Decorator.GetRot() & 0xF)));
463 for (
auto itr = a_Map.
GetData().cbegin(); itr != a_Map.
GetData().cend(); ++itr)
809 switch (a_PacketType)
819 switch (a_PacketType)
829 switch (a_PacketType)
927 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, RightPaddle);
928 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, LeftPaddle);
938 auto * Boat =
static_cast<cBoat *
>(Vehicle);
953 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, ChatColors);
1013 HANDLE_READ(a_ByteBuffer, ReadBEDouble,
double, PosX);
1014 HANDLE_READ(a_ByteBuffer, ReadBEDouble,
double, PosY);
1015 HANDLE_READ(a_ByteBuffer, ReadBEDouble,
double, PosZ);
1016 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, IsOnGround);
1030 HANDLE_READ(a_ByteBuffer, ReadBEDouble,
double, PosX);
1031 HANDLE_READ(a_ByteBuffer, ReadBEDouble,
double, PosY);
1032 HANDLE_READ(a_ByteBuffer, ReadBEDouble,
double, PosZ);
1033 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, Yaw);
1034 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, Pitch);
1035 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, IsOnGround);
1049 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, Sideways);
1050 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, Forward);
1053 if ((Flags & 0x2) != 0)
1057 else if ((Flags & 0x1) != 0)
1074 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, AssumeCommand);
1075 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, HasPosition);
1098 for (
int i = 0; i < 4; i++)
1135 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, TargetX);
1136 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, TargetY);
1137 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, TargetZ);
1145 ASSERT(!
"Unhandled use entity type!");
1169 HANDLE_READ(a_ByteBuffer, ReadBEDouble,
double, xPos);
1170 HANDLE_READ(a_ByteBuffer, ReadBEDouble,
double, yPos);
1171 HANDLE_READ(a_ByteBuffer, ReadBEDouble,
double, zPos);
1172 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, yaw);
1173 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, pitch);
1203 static const Int16 SLOT_NUM_OUTSIDE = -999;
1207 switch ((
Mode << 8) | Button)
1237 LOGWARNING(
"Unhandled window click mode / button combination: %d (0x%x)", (
Mode << 8) | Button, (
Mode << 8) | Button);
1252 if (a_Channel ==
"AutoCmd")
1258 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, TrackOutput);
1261 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, Automatic);
1265 else if (a_Channel ==
"PickItem")
1269 else if (a_Channel ==
"Struct")
1286 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, IgnoreEntities);
1287 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, ShowAir);
1288 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, ShowBoundingBox);
1289 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, Integrity);
1309 CreateHexDump(HexDump, a_Metadata.data(), std::max<size_t>(a_Metadata.size(), 1024), 16);
1310 LOGWARNING(
"Cannot parse NBT item metadata: %s at (%zu / %zu bytes)\n%s",
1324 if ((TagName ==
"ench") || (TagName ==
"StoredEnchantments"))
1332 if (TagName ==
"display")
1354 else if ((TagName ==
"Fireworks") || (TagName ==
"Explosion"))
1358 else if (TagName ==
"EntityTag")
1376 if (TagName ==
"RepairCost")
1384 if (TagName ==
"Potion")
1387 if (PotionEffect.find(
"minecraft:") == AString::npos)
1389 LOGD(
"Unknown or missing domain on potion effect name %s!", PotionEffect.c_str());
1393 if (PotionEffect.find(
"empty") != AString::npos)
1397 else if (PotionEffect.find(
"mundane") != AString::npos)
1401 else if (PotionEffect.find(
"thick") != AString::npos)
1405 else if (PotionEffect.find(
"awkward") != AString::npos)
1409 else if (PotionEffect.find(
"regeneration") != AString::npos)
1413 else if (PotionEffect.find(
"swiftness") != AString::npos)
1417 else if (PotionEffect.find(
"fire_resistance") != AString::npos)
1421 else if (PotionEffect.find(
"poison") != AString::npos)
1425 else if (PotionEffect.find(
"healing") != AString::npos)
1429 else if (PotionEffect.find(
"night_vision") != AString::npos)
1433 else if (PotionEffect.find(
"weakness") != AString::npos)
1437 else if (PotionEffect.find(
"strength") != AString::npos)
1441 else if (PotionEffect.find(
"slowness") != AString::npos)
1445 else if (PotionEffect.find(
"leaping") != AString::npos)
1449 else if (PotionEffect.find(
"harming") != AString::npos)
1453 else if (PotionEffect.find(
"water_breathing") != AString::npos)
1457 else if (PotionEffect.find(
"invisibility") != AString::npos)
1461 else if (PotionEffect.find(
"water") != AString::npos)
1470 LOGD(
"Unknown potion type for effect name %s!", PotionEffect.c_str());
1474 if (PotionEffect.find(
"strong") != AString::npos)
1478 if (PotionEffect.find(
"long") != AString::npos)
1497 default:
LOGD(
"Unimplemented NBT data when parsing!");
break;
1537 auto & MobSpawnerEntity =
static_cast<const cMobSpawnerEntity &
>(a_BlockEntity);
1544 a_Writer.
AddShort(
"Delay", MobSpawnerEntity.GetSpawnDelay());
1592 auto & Player =
static_cast<const cPlayer &
>(a_Entity);
1603 a_Pkt.
WriteBEFloat(
static_cast<float>(Player.GetHealth()));
1643 const cItem & MinecartContent = RideableMinecart.GetContent();
1644 if (!MinecartContent.
IsEmpty())
1673 switch (Projectile.GetProjectileKind())
1711 auto & Boat =
static_cast<const cBoat &
>(a_Entity);
1731 a_Pkt.
WriteBool(Boat.IsRightPaddleUsed());
1735 a_Pkt.
WriteBool(Boat.IsLeftPaddleUsed());
1742 auto & Frame =
static_cast<const cItemFrame &
>(a_Entity);
1754 const auto & EnderCrystal =
static_cast<const cEnderCrystal &
>(a_Entity);
1757 a_Pkt.
WriteBool(EnderCrystal.DisplaysBeam());
1758 if (EnderCrystal.DisplaysBeam())
1764 a_Pkt.
WriteBool(EnderCrystal.ShowsBottom());
1885 default:
ASSERT(!
"Unknown potion effect");
break;
1889 PotionID =
"strong_" + PotionID;
1894 PotionID =
"long_" + PotionID;
1909 case 0x00: PotionID =
"mundane";
break;
1910 case 0x10: PotionID =
"awkward";
break;
1911 case 0x20: PotionID =
"thick";
break;
1917 PotionID =
"minecraft:" + PotionID;
1971 auto & Bat =
static_cast<const cBat &
>(a_Mob);
1990 auto & Cow =
static_cast<const cCow &
>(a_Mob);
2017 auto & Enderman =
static_cast<const cEnderman &
>(a_Mob);
2021 Carried |=
static_cast<UInt32>(Enderman.GetCarriedBlock() << 4);
2022 Carried |= Enderman.GetCarriedMeta();
2027 a_Pkt.
WriteBool(Enderman.IsScreaming());
2033 auto & Ghast =
static_cast<const cGhast &
>(a_Mob);
2042 auto & Horse =
static_cast<const cHorse &
>(a_Mob);
2048 if (Horse.IsSaddled())
2052 if (Horse.IsChested())
2056 if (Horse.IsEating())
2060 if (Horse.IsRearing())
2064 if (Horse.IsMthOpen())
2079 Appearance = Horse.GetHorseColor();
2080 Appearance |= Horse.GetHorseStyle() << 8;
2095 auto & MagmaCube =
static_cast<const cMagmaCube &
>(a_Mob);
2104 auto & Ocelot =
static_cast<const cOcelot &
>(a_Mob);
2114 auto & Pig =
static_cast<const cPig &
>(a_Mob);
2142 auto & Sheep =
static_cast<const cSheep &
>(a_Mob);
2150 Int8 SheepMetadata = 0;
2151 SheepMetadata =
static_cast<Int8>(Sheep.GetFurColor());
2152 if (Sheep.IsSheared())
2154 SheepMetadata |= 0x10;
2162 auto & Skeleton =
static_cast<const cSkeleton &
>(a_Mob);
2170 a_Pkt.
WriteBEInt8(0x02 | (Skeleton.IsChargingBow() ? 0x01 : 0x00));
2174 a_Pkt.
WriteBool(Skeleton.IsChargingBow());
2180 auto & Slime =
static_cast<const cSlime &
>(a_Mob);
2189 auto & Villager =
static_cast<const cVillager &
>(a_Mob);
2202 auto & Witch =
static_cast<const cWitch &
>(a_Mob);
2211 auto & Wither =
static_cast<const cWither &
>(a_Mob);
2230 auto & Wolf =
static_cast<const cWolf &
>(a_Mob);
2235 Int8 WolfStatus = 0;
2236 if (Wolf.IsSitting())
2268 auto & Zombie =
static_cast<const cZombie &
>(a_Mob);
2285 auto & ZombiePigman =
static_cast<const cZombiePigman &
>(a_Mob);
2294 auto & ZombieVillager =
reinterpret_cast<const cZombieVillager &
>(a_Mob);
2297 a_Pkt.
WriteBool(ZombieVillager.IsBaby());
2305 a_Pkt.
WriteBool(ZombieVillager.ConversionTime() != -1);
2331 ASSERT(!
"cProtocol_1_9::WriteMobMetadata: received unimplemented type");
2350 default:
UNREACHABLE(
"cProtocol_1_9::WriteMobMetadata: received mob of invalid type");
2427 Writer.
AddInt(
"x", a_BlockPos.
x);
2428 Writer.
AddInt(
"y", a_BlockPos.
y);
2429 Writer.
AddInt(
"z", a_BlockPos.
z);
2433 Line1[
"text"] = a_Line1;
2436 Line2[
"text"] = a_Line2;
2439 Line3[
"text"] = a_Line3;
2442 Line4[
"text"] = a_Line4;
eClickAction
Individual actions sent in the WindowClick packet.
@ caLeftClickOutsideHoldNothing
@ caRightClickOutsideHoldNothing
std::basic_string_view< std::byte > ContiguousByteBufferView
unsigned long long UInt64
void LOGWARNING(std::string_view a_Format, const Args &... args)
void LOG(std::string_view a_Format, const Args &... args)
eMonsterType
Identifies individual monster type.
#define HANDLE_READ(ByteBuf, Proc, Type, Var)
Macros used to read packets more easily.
void ReplaceString(AString &iHayStack, const AString &iNeedle, const AString &iReplaceWith)
Replaces each occurence of iNeedle in iHayStack with iReplaceWith.
AString & CreateHexDump(AString &a_Out, const void *a_Data, size_t a_Size, size_t a_BytesPerLine)
format binary data this way: 00001234: 31 32 33 34 35 36 37 38 39 30 61 62 63 64 65 66 1234567890abcd...
AString WriteFastString(const Json::Value &a_Root)
bool Conditional(const BlockState Block)
void ParseFromNBT(cEnchantments &a_Enchantments, const cParsedNBT &a_NBT, int a_EnchListTagIdx)
Reads the enchantments from the specified NBT list tag (ench or StoredEnchantments)
void WriteToNBTCompound(const cEnchantments &a_Enchantments, cFastNBTWriter &a_Writer, const AString &a_ListTagName)
Writes the enchantments into the specified NBT writer; begins with the LIST tag of the specified name...
BLOCKTYPE GetBlockType() const
An object that can store incoming bytes and lets its clients read the bytes sequentially The bytes ar...
static bool CanBEInt16Represent(int a_Value)
Returns if the given value can fit in a protocol big-endian 16 bit integer.
bool ReadXYZPosition64(int &a_BlockX, int &a_BlockY, int &a_BlockZ)
void HandleCommandBlockBlockChange(Vector3i a_BlockPos, const AString &a_NewCommand)
Called when the protocol receives a message, indicating that the player set a new command in the comm...
void SetLocale(const AString &a_Locale)
void HandleLeftClick(Vector3i a_BlockPos, eBlockFace a_BlockFace, UInt8 a_Status)
void SetViewDistance(int a_ViewDistance)
Sets the maximal view distance.
void PacketUnknown(UInt32 a_PacketType)
void HandleWindowClick(UInt8 a_WindowID, Int16 a_SlotNum, eClickAction a_ClickAction, const cItem &a_HeldItem)
void HandleLeaveBed()
Handles a player exiting his bed.
void HandleRightClick(Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_Cursor, bool a_UsedMainHand)
void HandleUseEntity(UInt32 a_TargetEntityID, bool a_IsLeftClick)
void HandleUpdateSign(Vector3i a_BlockPos, const AString &a_Line1, const AString &a_Line2, const AString &a_Line3, const AString &a_Line4)
void HandleSteerVehicle(float Forward, float Sideways)
void HandleStartElytraFlight()
Handles a player starting elytra flight while falling.
void HandleUseItem(bool a_UsedMainHand)
void HandleSprint(bool a_IsSprinting)
Handles a player sprinting or slowing back down.
const AString & GetUsername(void) const
void HandlePlayerMove(Vector3d a_Pos, bool a_IsOnGround)
Verifies and sets player position, performing relevant checks.
void HandleTabCompletion(const AString &a_Text)
void HandleCrouch(bool a_IsCrouching)
Handles a player sneaking or unsneaking.
cPlayer * GetPlayer(void)
void HandlePlayerMoveLook(Vector3d a_Pos, float a_Rotation, float a_Pitch, bool a_IsOnGround)
void HandleOpenHorseInventory()
Handles a player opening his inventory while riding a horse.
void HandleAnimation(bool a_SwingMainHand)
Called when the protocol receives a (hand swing) animation packet.
bool IsValid() const
Returns whether the color is a valid color.
Container for a single chat message composed of multiple functional parts.
AString CreateJsonString(bool a_ShouldUseChatPrefixes=true) const
bool IsEmpty(void) const
Returns true if there are no enchantments.
bool IsCritical(void) const
Returns true if the arrow is set as critical.
void UpdatePaddles(bool rightPaddleUsed, bool leftPaddleUsed)
virtual bool IsElytraFlying(void) const
virtual bool IsRclking(void) const
void SetPitch(double a_Pitch)
double GetSpeedZ(void) const
void SetYaw(double a_Yaw)
virtual bool IsCrouched(void) const
float GetMaxHealth(void) const
double GetSpeedY(void) const
Vector3d GetLastSentPosition(void) const
Returns the last position we sent to all the clients.
double GetPosX(void) const
void SetPosY(double a_PosY)
double GetPosZ(void) const
UInt32 GetUniqueID(void) const
eEntityType GetEntityType(void) const
double GetPitch(void) const
virtual bool IsOnFire(void) const
bool IsOrientationDirty() const
Returns whether the entity's orientation has been set manually.
double GetPosY(void) const
double GetHeadYaw(void) const
virtual bool IsOnGround(void) const
Returns whether the entity is on ground or not.
void SetPosZ(double a_PosZ)
void SetPosX(double a_PosX)
cEntity * GetAttached()
Gets entity (vehicle) attached to this entity.
virtual bool IsInvisible(void) const
double GetYaw(void) const
float GetHealth(void) const
Returns the health of this entity.
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
virtual bool IsSprinting(void) const
double GetSpeedX(void) const
eType
All types of entity effects (numbers correspond to protocol / storage types)
static short GetPotionEffectIntensity(short a_ItemDamage)
Retrieves the intensity level from the potion's damage value.
static cEntityEffect::eType GetPotionEffectType(short a_ItemDamage)
Translates the potion's damage value into the entity effect that the potion gives.
int GetReward(void) const
Get the exp amount.
Byte GetProtocolFacing() const
Returns the direction in which the entity is facing.
bool IsFueled(void) const
const AString & GetName(void) const
Returns the protocol name of the painting.
const cUUID & GetUUID(void) const
Returns the UUID that has been read from the client, or nil if not available.
void SetSkinParts(int a_Parts)
void SetLeftHanded(bool a_IsLeftHanded)
Sets the dominant hand of the player.
bool HasPermission(const AString &a_Permission) const
eGameMode GetEffectiveGameMode(void) const
Returns the current effective gamemode (inherited gamemode is resolved before returning)
bool IsBothNameAndLoreEmpty(void) const
cEnchantments m_Enchantments
bool IsCustomNameEmpty(void) const
bool IsEmpty(void) const
Returns true if the item represents an empty stack - either the type is invalid, or count is zero.
bool IsLoreEmpty(void) const
AStringVector m_LoreTable
cFireworkItem m_FireworkItem
static eMonsterType ItemDamageToMonsterType(short a_ItemDamage)
Converts the Spawn egg item damage to the monster type to spawn.
Encapsulates an in-game world map.
const cMapDecoratorList GetDecorators(void) const
const cColorList & GetData(void) const
unsigned int GetScale(void) const
unsigned int GetID(void) const
static AString MobTypeToVanillaName(eMonsterType a_MobType)
Translates MobType enum to the vanilla name of the mob, empty string if unknown.
bool HasCustomName(void) const
Returns true if the monster has a custom name.
const AString & GetCustomName(void) const
Gets the custom name of the monster.
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...
eMonsterType GetMobType(void) const
static AString MobTypeToVanillaNBT(eMonsterType a_MobType)
Translates the MobType enum to the vanilla nbt name.
static eMonsterType StringToMobType(const AString &a_MobTypeName)
Translates MobType string to the enum, mtInvalidType if not recognized.
Composes an individual packet in the protocol's m_OutPacketBuffer; sends it just before being destruc...
void WriteVarInt32(UInt32 a_Value)
void WriteUUID(const cUUID &a_UUID)
Writes the specified UUID as a 128-bit BigEndian integer.
void WriteBEUInt32(UInt32 a_Value)
void WriteBEInt32(Int32 a_Value)
void WriteBool(bool a_Value)
void WriteXYZPosition64(int a_BlockX, int a_BlockY, int a_BlockZ)
Writes the specified block position as a single encoded 64-bit BigEndian integer.
void WriteBEUInt64(UInt64 a_Value)
void WriteBEFloat(float a_Value)
void WriteBEInt16(Int16 a_Value)
void WriteString(const AString &a_Value)
void WriteBEUInt8(UInt8 a_Value)
void WriteBEDouble(double a_Value)
void WriteBuf(const ContiguousByteBufferView a_Data)
void WriteByteAngle(double a_Angle)
Writes the specified angle using a single byte.
void WriteBEInt8(Int8 a_Value)
ePacketType
Logical types of outgoing packets.
@ pktTabCompletionResults
@ pktPlayerListHeaderFooter
@ pktDisconnectDuringGame
@ pktDisconnectDuringLogin
Version
The protocol version number, received from the client in the Handshake packet.
virtual void HandlePacketPlayer(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketStatusPing(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketLoginEncryptionResponse(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketEnchantItem(cByteBuffer &a_ByteBuffer)
virtual UInt32 GetProtocolMobType(eMonsterType a_MobType) const
Converts eMonsterType to protocol-specific mob types.
virtual unsigned char GetProtocolEntityAnimation(EntityAnimation a_Animation) const
Converts an animation into an ID suitable for use with the Entity Animation packet.
virtual void WriteBlockEntity(cFastNBTWriter &a_Writer, const cBlockEntity &a_BlockEntity) const
Writes the block entity data for the specified block entity into the packet.
virtual void HandlePacketLoginStart(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketCreativeInventoryAction(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketWindowClose(cByteBuffer &a_ByteBuffer)
virtual void HandleVanillaPluginMessage(cByteBuffer &a_ByteBuffer, std::string_view a_Channel)
Parses Vanilla plugin messages into specific ClientHandle calls.
virtual void HandlePacketStatusRequest(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketPluginMessage(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketPlayerAbilities(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketChatMessage(cByteBuffer &a_ByteBuffer)
State m_State
State of the protocol.
virtual void HandlePacketKeepAlive(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketResourcePackStatus(cByteBuffer &a_ByteBuffer)
virtual bool ReadItem(cByteBuffer &a_ByteBuffer, cItem &a_Item, size_t a_KeepRemainingBytes=0) const
Reads an item out of the received data, sets a_Item to the values read.
static eBlockFace FaceIntToBlockFace(Int32 a_FaceInt)
Converts the BlockFace received by the protocol into eBlockFace constants.
virtual void HandlePacketPlayerLook(cByteBuffer &a_ByteBuffer)
virtual signed char GetProtocolEntityStatus(EntityAnimation a_Animation) const
Converts an animation into an ID suitable for use with the Entity Status packet.
virtual void HandlePacketClientStatus(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketSlotSelect(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketSpectate(cByteBuffer &a_ByteBuffer)
virtual void SendSpawnMob(const cMonster &a_Mob) override
virtual void HandlePacketSteerVehicle(cByteBuffer &a_ByteBuffer) override
virtual void SendEntitySpawn(const cEntity &a_Entity, const UInt8 a_ObjectType, const Int32 a_ObjectData) override
Sends the entity type and entity-dependent data required for the entity to initially spawn.
virtual Version GetProtocolVersion() const override
Returns the protocol version.
virtual void WriteMobMetadata(cPacketizer &a_Pkt, const cMonster &a_Mob) const override
Writes the mob-specific metadata for the specified mob.
virtual void HandlePacketUseEntity(cByteBuffer &a_ByteBuffer) override
cProtocol_1_9_0(cClientHandle *a_Client, const AString &a_ServerAddress, State a_State)
virtual void SendKeepAlive(UInt32 a_PingID) override
virtual unsigned char GetProtocolEntityAnimation(EntityAnimation a_Animation) const override
Converts an animation into an ID suitable for use with the Entity Animation packet.
virtual UInt32 GetProtocolMobType(eMonsterType a_MobType) const override
Converts eMonsterType to protocol-specific mob types.
virtual void SendEntityEquipment(const cEntity &a_Entity, short a_SlotNum, const cItem &a_Item) override
virtual void HandlePacketBlockPlace(cByteBuffer &a_ByteBuffer) override
virtual void WriteItem(cPacketizer &a_Pkt, const cItem &a_Item) const override
Writes the item data into a packet.
virtual void SendPaintingSpawn(const cPainting &a_Painting) override
virtual void HandlePacketPlayerPos(cByteBuffer &a_ByteBuffer) override
virtual void SendDetachEntity(const cEntity &a_Entity, const cEntity &a_PreviousVehicle) override
virtual void SendBossBarUpdateTitle(UInt32 a_UniqueID, const cCompositeChat &a_Title) override
virtual void SendEntityMetadata(const cEntity &a_Entity) override
virtual void HandlePacketUseItem(cByteBuffer &a_ByteBuffer)
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.
UInt32 m_OutstandingTeleportId
Whether the current teleport ID has been confirmed by the client.
virtual void SendUnloadChunk(int a_ChunkX, int a_ChunkZ) override
virtual void SendPlayerSpawn(const cPlayer &a_Player) override
virtual void SendBossBarUpdateFlags(UInt32 a_UniqueID, bool a_DarkenSky, bool a_PlayEndMusic, bool a_CreateFog) override
virtual void SendMapData(const cMap &a_Map, int a_DataStartX, int a_DataStartY) override
virtual UInt32 GetPacketID(ePacketType a_Packet) const override
Get the packet ID for a given packet.
virtual void HandlePacketWindowClick(cByteBuffer &a_ByteBuffer) override
virtual void HandlePacketClientSettings(cByteBuffer &a_ByteBuffer) 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 void SendPlayerPermissionLevel() 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 SendEntityPosition(const cEntity &a_Entity) override
virtual void WriteEntityMetadata(cPacketizer &a_Pkt, const cEntity &a_Entity) const override
Writes the metadata for the specified entity, not including the terminating 0x7f.
virtual void HandlePacketEntityAction(cByteBuffer &a_ByteBuffer) override
virtual void SendBossBarUpdateStyle(UInt32 a_UniqueID, BossBarColor a_Color, BossBarDivisionType a_DivisionType) override
virtual void SendSoundEffect(const AString &a_SoundName, Vector3d a_Origin, float a_Volume, float a_Pitch) override
virtual void HandlePacketPlayerPosLook(cByteBuffer &a_ByteBuffer) override
virtual void SendBossBarUpdateHealth(UInt32 a_UniqueID, float a_FractionFilled) override
virtual void SendBossBarRemove(UInt32 a_UniqueID) override
virtual bool HandlePacket(cByteBuffer &a_ByteBuffer, UInt32 a_PacketType) override
Reads and handles the packet.
virtual void SendUnleashEntity(const cEntity &a_Entity) override
virtual void SendPlayerMoveLook(void) override
virtual void HandlePacketBoatSteer(cByteBuffer &a_ByteBuffer)
virtual void HandleConfirmTeleport(cByteBuffer &a_ByteBuffer)
@ METADATA_TYPE_OPTIONAL_POSITION
virtual void HandleVanillaPluginMessage(cByteBuffer &a_ByteBuffer, std::string_view a_Channel) override
Parses Vanilla plugin messages into specific ClientHandle calls.
virtual void SendThunderbolt(Vector3i a_Origin) override
virtual void HandlePacketUpdateSign(cByteBuffer &a_ByteBuffer) override
virtual void HandlePacketBlockDig(cByteBuffer &a_ByteBuffer) override
virtual void SendLeashEntity(const cEntity &a_Entity, const cEntity &a_EntityLeashedTo) override
virtual void HandlePacketAnimation(cByteBuffer &a_ByteBuffer) override
virtual void SendAttachEntity(const cEntity &a_Entity, const cEntity &a_Vehicle) override
virtual void HandlePacketVehicleMove(cByteBuffer &a_ByteBuffer)
virtual void SendExperienceOrb(const cExpOrb &a_ExpOrb) override
virtual void HandlePacketTabComplete(cByteBuffer &a_ByteBuffer) override
bool m_IsTeleportIdConfirmed
The current teleport ID.
virtual signed char GetProtocolEntityStatus(EntityAnimation a_Animation) const override
Converts an animation into an ID suitable for use with the Entity Status packet.
virtual Version GetProtocolVersion() const override
Returns the protocol version.
virtual void SendLogin(const cPlayer &a_Player, const cWorld &a_World) override
virtual Version GetProtocolVersion() const override
Returns the protocol version.
virtual UInt32 GetPacketID(ePacketType a_Packet) const override
Get the packet ID for a given packet.
virtual Version GetProtocolVersion() const override
Returns the protocol version.
virtual void SendUpdateSign(Vector3i a_BlockPos, const AString &a_Line1, const AString &a_Line2, const AString &a_Line3, const AString &a_Line4) override
cServer * GetServer(void)
size_t GetMaxPlayers(void) const
bool IsHardcore(void) const
int GetSpawnX(void) const
int GetSpawnZ(void) const
virtual eDimension GetDimension(void) const override
int GetSpawnY(void) const
Parses and contains the parsed data Also implements data accessor functions for tree traversal and va...
int GetNextSibling(int a_Tag) const
Returns the next sibling of the specified tag, or -1 if none.
size_t GetErrorPos() const
Returns the position where an error occurred while parsing.
std::error_code GetErrorCode() const
Returns the error code for the parsing of the NBT data.
int GetFirstChild(int a_Tag) const
Returns the first child of the specified tag, or -1 if none / not applicable.
AString GetName(int a_Tag) const
Returns the tag's name.
eTagType GetType(int a_Tag) const
int GetRoot(void) const
Returns the root tag of the hierarchy.
Int32 GetInt(int a_Tag) const
Returns the value stored in an Int tag.
AString GetString(int a_Tag) const
Returns the value stored in a String tag.
void AddShort(const AString &a_Name, Int16 a_Value)
void AddInt(const AString &a_Name, Int32 a_Value)
void AddString(const AString &a_Name, std::string_view a_Value)
void BeginList(const AString &a_Name, eTagType a_ChildrenType)
void BeginCompound(const AString &a_Name)
ContiguousByteBufferView GetResult(void) const
static void WriteToNBTCompound(const cFireworkItem &a_FireworkItem, cFastNBTWriter &a_Writer, const ENUM_ITEM_TYPE a_Type)
Writes firework NBT data to a Writer object.
static void ParseFromNBT(cFireworkItem &a_FireworkItem, const cParsedNBT &a_NBT, int a_TagIdx, const ENUM_ITEM_TYPE a_Type)
Reads NBT data from a NBT object and populates a FireworkItem with it.