13 #include "../mbedTLS++/Sha1Checksum.h"
16 #include "../ClientHandle.h"
18 #include "../Server.h"
20 #include "../EffectID.h"
21 #include "../StringCompression.h"
22 #include "../CompositeChat.h"
25 #include "../JsonUtils.h"
27 #include "../WorldStorage/FastNBT.h"
28 #include "../WorldStorage/EnchantmentSerializer.h"
30 #include "../Entities/ExpOrb.h"
31 #include "../Entities/Minecart.h"
32 #include "../Entities/FallingBlock.h"
33 #include "../Entities/Floater.h"
34 #include "../Entities/Painting.h"
35 #include "../Entities/Pickup.h"
36 #include "../Entities/Player.h"
37 #include "../Entities/ItemFrame.h"
38 #include "../Entities/ArrowEntity.h"
39 #include "../Entities/FireworkEntity.h"
41 #include "../Mobs/IncludeAllMonsters.h"
42 #include "../UI/Window.h"
43 #include "../UI/HorseWindow.h"
45 #include "../BlockEntities/BannerEntity.h"
46 #include "../BlockEntities/BeaconEntity.h"
47 #include "../BlockEntities/CommandBlockEntity.h"
48 #include "../BlockEntities/EnchantingTableEntity.h"
49 #include "../BlockEntities/MobHeadEntity.h"
50 #include "../BlockEntities/MobSpawnerEntity.h"
51 #include "../BlockEntities/FlowerPotEntity.h"
52 #include "../Bindings/PluginManager.h"
71 m_ServerAddress(a_ServerAddress),
77 if (Params.size() >= 2)
81 if (Params[1] ==
"FML")
83 LOGD(
"Forge client connected!");
86 else if (Params.size() == 4)
88 if (
cRoot::Get()->GetServer()->ShouldAllowBungeeCord())
94 LOGD(
"Player at %s connected via BungeeCord", Params[1].c_str());
102 LOGERROR(
"Unable to parse player properties: '%s'", Params[3]);
112 LOG(
"BungeeCord is disabled, but client sent additional data, set AllowBungeeCord=1 if you want to allow it");
117 LOG(
"Unknown additional data sent in server address (BungeeCord/FML?): %zu parameters", Params.size());
125 static int sCounter = 0;
129 auto FileName = fmt::format(FMT_STRING(
"CommLogs/{:x}_{}__{}.log"),
130 static_cast<unsigned>(time(
nullptr)),
136 LOG(
"Cannot log communication to file, the log file \"%s\" cannot be opened for writing.", FileName.c_str());
236 for (
const auto & Change : a_Changes)
238 Int16 Coords =
static_cast<Int16>(Change.m_RelY | (Change.m_RelZ << 8) | (Change.m_RelX << 12));
240 Pkt.
WriteVarInt32(
static_cast<UInt32>(Change.m_BlockType & 0xFFF) << 4 | (Change.m_BlockMeta & 0xF));
339 if (a_MessageRaw.find(
"${") != std::string::npos)
399 if (!a_Entity.
IsMob())
404 const auto & Mob =
static_cast<const cMonster &
>(a_Entity);
448 "Tried to send disconnect in invalid game state {0}",
478 const auto BedPosition =
static_cast<const cPlayer &
>(a_Entity).GetLastBedPos();
586 Delta.HasNonZeroLength() &&
744 ASSERT((a_ItemIndex >= 0) && (a_ItemIndex <= 8));
785 LOGWARNING(
"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);
883 double PosX = a_Painting.
GetPosX();
884 double PosY = a_Painting.
GetPosY();
885 double PosZ = a_Painting.
GetPosZ();
909 Pkt.
WriteBEUInt8(
static_cast<Byte>((
static_cast<Int32>(Decorator.GetType()) << 4) | (Decorator.GetRot() & 0xF)));
919 for (
auto itr = a_Map.
GetData().cbegin(); itr != a_Map.
GetData().cend(); ++itr)
1038 for (
auto & Node : Properties)
1041 Pkt.
WriteString(Node.get(
"value",
"").asString());
1042 AString Signature = Node.get(
"signature",
"").asString();
1043 if (Signature.empty())
1099 if (a_CustomName.empty())
1270 Checksum.
Update(
reinterpret_cast<const Byte *
>(a_ResourcePackUrl.c_str()), a_ResourcePackUrl.size());
1305 if ((a_Mode == 0) || (a_Mode == 2))
1426 Int32 EntityData = 1;
1431 const auto & Cart =
static_cast<const cMinecart &
>(a_Entity);
1432 EntityData =
static_cast<Int32>(Cart.GetPayload());
1436 const auto & Frame =
static_cast<const cItemFrame &
>(a_Entity);
1437 EntityData =
static_cast<Int32>(Frame.GetProtocolFacing());
1442 EntityData =
Block.GetBlockType() | (
static_cast<Int32>(
Block.GetBlockMeta()) << 12);
1446 const auto & Floater =
static_cast<const cFloater &
>(a_Entity);
1447 EntityData =
static_cast<Int32>(Floater.GetOwnerID());
1454 if (Projectile.GetProjectileKind() == PType::pkArrow)
1457 EntityData =
static_cast<Int32>(
Arrow.GetCreatorUniqueID() + 1);
1511 for (
const auto & [Statistic, Value] : a_Manager.
Custom)
1529 for (AStringVector::const_iterator itr = a_Results.begin(), end = a_Results.end(); itr != end; ++itr)
1577 if (a_DoDaylightCycle)
1585 Pkt.
WriteBEInt64(std::min(-a_WorldDate.count(), -1LL));
1659 AString Lines[] = { a_Line1, a_Line2, a_Line3, a_Line4 };
1660 for (
size_t i = 0; i <
ARRAYCOUNT(Lines); i++)
1716 for (cItems::const_iterator itr = Slots.begin(), end = Slots.end(); itr != end; ++itr)
1796 const auto Uncompressed = a_Packet.
GetView();
1810 const UInt32 DataSize = 0;
1822 LengthHeaderBuffer.
ReadAll(LengthData);
1824 a_CompressedData.reserve(LengthData.size() + Uncompressed.size());
1825 a_CompressedData = LengthData;
1826 a_CompressedData += Uncompressed;
1842 const auto CompressedData = a_Packet.
Compress();
1843 const auto Compressed = CompressedData.
GetView();
1845 const UInt32 DataSize =
static_cast<UInt32>(Uncompressed.size());
1857 LengthHeaderBuffer.
ReadAll(LengthData);
1859 a_CompressedData.reserve(LengthData.size() + Compressed.size());
1860 a_CompressedData = LengthData;
1861 a_CompressedData += Compressed;
1872 switch (a_BlockFace)
1890 switch (a_PacketType)
1969 ASSERT(!
"Unhandled outgoing packet type");
1981 switch (a_Animation)
1988 default:
return static_cast<unsigned char>(-1);
1998 switch (a_Animation)
2043 case mtBat:
return 65;
2047 case mtCow:
return 92;
2060 case mtPig:
return 90;
2110 switch (a_PacketType)
2120 switch (a_PacketType)
2130 switch (a_PacketType)
2188 auto NumPlayers =
static_cast<signed>(Server->
GetNumPlayers());
2189 auto MaxPlayers =
static_cast<signed>(Server->
GetMaxPlayers());
2198 Version[
"protocol"] =
static_cast<std::underlying_type_t<cProtocol::Version>
>(ProtocolVersion);
2201 Json::Value Players;
2202 Players[
"online"] = NumPlayers;
2203 Players[
"max"] = MaxPlayers;
2207 Json::Value Description;
2208 Description[
"text"] = std::move(ServerDescription);
2211 Json::Value ResponseValue;
2212 ResponseValue[
"version"] =
Version;
2213 ResponseValue[
"players"] = Players;
2214 ResponseValue[
"description"] = Description;
2216 if (!Favicon.empty())
2218 ResponseValue[
"favicon"] =
"data:image/png;base64," + Favicon;
2232 UInt32 EncKeyLength, EncNonceLength;
2238 if (!a_ByteBuffer.
ReadSome(EncKey, EncKeyLength))
2242 if (!a_ByteBuffer.
ReadVarInt(EncNonceLength))
2247 if (!a_ByteBuffer.
ReadSome(EncNonce, EncNonceLength))
2253 LOGD(
"Too long encryption");
2261 int res = rsaDecryptor.
Decrypt(EncNonce,
reinterpret_cast<Byte *
>(DecryptedNonce),
sizeof(DecryptedNonce));
2264 LOGD(
"Bad nonce length: got %d, exp %d", res, 4);
2268 if (ntohl(DecryptedNonce[0]) !=
static_cast<unsigned>(
reinterpret_cast<uintptr_t
>(
this)))
2270 LOGD(
"Bad nonce value");
2277 res = rsaDecryptor.
Decrypt(EncKey, DecryptedKey,
sizeof(DecryptedKey));
2280 LOGD(
"Bad key length");
2311 if (
const auto Server =
cRoot::Get()->GetServer(); Server->ShouldAuthenticate())
2315 const auto PubKeyDer = Server->GetPublicKeyDER();
2319 Pkt.
WriteBEInt32(
static_cast<int>(
reinterpret_cast<intptr_t
>(
this)));
2406 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, ChatColors);
2506 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, IsOnGround);
2517 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, FlyingSpeed);
2518 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, WalkingSpeed);
2521 bool IsFlying =
false;
2522 if ((Flags & 2) != 0)
2536 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, Yaw);
2537 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, Pitch);
2538 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, IsOnGround);
2549 HANDLE_READ(a_ByteBuffer, ReadBEDouble,
double, PosX);
2550 HANDLE_READ(a_ByteBuffer, ReadBEDouble,
double, PosY);
2551 HANDLE_READ(a_ByteBuffer, ReadBEDouble,
double, PosZ);
2552 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, IsOnGround);
2563 HANDLE_READ(a_ByteBuffer, ReadBEDouble,
double, PosX);
2564 HANDLE_READ(a_ByteBuffer, ReadBEDouble,
double, PosY);
2565 HANDLE_READ(a_ByteBuffer, ReadBEDouble,
double, PosZ);
2566 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, Yaw);
2567 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, Pitch);
2568 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, IsOnGround);
2583 const std::string_view ChannelView = Channel;
2586 if (ChannelView.substr(0, 3) ==
"MC|")
2629 if (!a_ByteBuffer.
ReadUUID(playerUUID))
2643 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, Sideways);
2644 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, Forward);
2647 if ((Flags & 0x2) != 0)
2651 else if ((Flags & 0x1) != 0)
2668 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, HasPosition);
2692 for (
int i = 0; i < 4; i++)
2698 Lines[i] = root.asString();
2728 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, TargetX);
2729 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, TargetY);
2730 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, TargetZ);
2737 ASSERT(!
"Unhandled use entity type!");
2771 static const Int16 SLOT_NUM_OUTSIDE = -999;
2775 switch ((
Mode << 8) | Button)
2805 LOGWARNING(
"Unhandled window click mode / button combination: %d (0x%x)", (
Mode << 8) | Button, (
Mode << 8) | Button);
2831 if ((a_Channel ==
"AdvCdm") || (a_Channel ==
"AdvCmd"))
2843 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, TrackOutput);
2853 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, TrackOutput);
2861 LOGD(
"Player \"%s\" sent an invalid command block edit type - hacked client?",
m_Client->
GetUsername().c_str());
2866 else if (a_Channel ==
"Beacon")
2873 else if (a_Channel ==
"BEdit")
2875 if (
cItem UnsignedBook;
ReadItem(a_ByteBuffer, UnsignedBook))
2880 else if (a_Channel ==
"BSign")
2887 else if (a_Channel ==
"Brand")
2894 else if (a_Channel ==
"ItemName")
2900 else if (a_Channel ==
"TrSel")
2919 CreateHexDump(HexDump, a_Metadata.data(), std::max<size_t>(a_Metadata.size(), 1024), 16);
2920 LOGWARNING(
"Cannot parse NBT item metadata: %s at (%zu / %zu bytes)\n%s",
2934 if ((TagName ==
"ench") || (TagName ==
"StoredEnchantments"))
2942 if (TagName ==
"display")
2963 else if ((TagName ==
"Fireworks") || (TagName ==
"Explosion"))
2971 if (TagName ==
"RepairCost")
2977 default:
LOGD(
"Unimplemented NBT data when parsing!");
break;
3037 if (a_ObjectData != 0)
3085 ASSERT(PacketData.size() > 0);
3086 CreateHexDump(Hex, PacketData.data(), PacketData.size(), 16);
3088 FMT_STRING(
"Outgoing packet: type {} (translated to 0x{:02x}), length {} (0x{:04x}), state {}. Payload (incl. type):\n{}\n"),
3090 PacketData.size(), PacketData.size(),
m_State, Hex
3117 auto & BannerEntity =
static_cast<const cBannerEntity &
>(a_BlockEntity);
3118 a_Writer.
AddInt(
"Base",
static_cast<Int32>(BannerEntity.GetBaseColor()));
3130 a_Writer.
AddByte(
"TrackOutput", 1);
3131 a_Writer.
AddInt(
"SuccessCount", CommandBlockEntity.GetResult());
3132 a_Writer.
AddString(
"Command", CommandBlockEntity.GetCommand());
3137 if (!CommandBlockEntity.GetLastOutput().empty())
3151 auto & MobHeadEntity =
static_cast<const cMobHeadEntity &
>(a_BlockEntity);
3152 a_Writer.
AddByte(
"SkullType", MobHeadEntity.GetType() & 0xFF);
3153 a_Writer.
AddByte(
"Rot", MobHeadEntity.GetRotation() & 0xFF);
3157 a_Writer.
AddString(
"Id", MobHeadEntity.GetOwnerUUID().ToShortString());
3158 a_Writer.
AddString(
"Name", MobHeadEntity.GetOwnerName());
3162 a_Writer.
AddString(
"Signature", MobHeadEntity.GetOwnerTextureSignature());
3163 a_Writer.
AddString(
"Value", MobHeadEntity.GetOwnerTexture());
3172 auto & FlowerPotEntity =
static_cast<const cFlowerPotEntity &
>(a_BlockEntity);
3173 a_Writer.
AddInt(
"Item",
static_cast<Int32>(FlowerPotEntity.GetItem().m_ItemType));
3174 a_Writer.
AddInt(
"Data",
static_cast<Int32>(FlowerPotEntity.GetItem().m_ItemDamage));
3179 auto & MobSpawnerEntity =
static_cast<const cMobSpawnerEntity &
>(a_BlockEntity);
3181 a_Writer.
AddShort(
"Delay", MobSpawnerEntity.GetSpawnDelay());
3234 auto & Player =
static_cast<const cPlayer &
>(a_Entity);
3242 a_Pkt.
WriteBEFloat(
static_cast<float>(Player.GetHealth()));
3277 const cItem & MinecartContent = RideableMinecart.GetContent();
3278 if (!MinecartContent.
IsEmpty())
3301 switch (Projectile.GetProjectileKind())
3331 auto & Frame =
static_cast<const cItemFrame &
>(a_Entity);
3354 const auto & Player =
static_cast<const cPlayer &
>(a_Entity);
3363 if (Player.IsSprinting())
3368 a_Pkt.
WriteBEDouble(Player.GetSprintingMaxSpeed() - Player.GetNormalMaxSpeed());
3491 auto & Bat =
static_cast<const cBat &
>(a_Mob);
3507 auto & Cow =
static_cast<const cCow &
>(a_Mob);
3509 a_Pkt.
WriteBEInt8(Cow.IsBaby() ? -1 : (Cow.IsInLoveCooldown() ? 1 : 0));
3525 auto & Enderman =
static_cast<const cEnderman &
>(a_Mob);
3537 auto & Ghast =
static_cast<const cGhast &
>(a_Mob);
3545 auto & Horse =
static_cast<const cHorse &
>(a_Mob);
3551 if (Horse.IsSaddled())
3555 if (Horse.IsChested())
3559 if (Horse.IsEating())
3563 if (Horse.IsRearing())
3567 if (Horse.IsMthOpen())
3577 Appearance = Horse.GetHorseColor();
3578 Appearance |= Horse.GetHorseStyle() << 8;
3583 a_Pkt.
WriteBEInt8(Horse.IsBaby() ? -1 : (Horse.IsInLoveCooldown() ? 1 : 0));
3589 auto & MagmaCube =
static_cast<const cMagmaCube &
>(a_Mob);
3597 auto & Ocelot =
static_cast<const cOcelot &
>(a_Mob);
3599 a_Pkt.
WriteBEInt8(Ocelot.IsBaby() ? -1 : (Ocelot.IsInLoveCooldown() ? 1 : 0));
3605 auto & Pig =
static_cast<const cPig &
>(a_Mob);
3607 a_Pkt.
WriteBEInt8(Pig.IsBaby() ? -1 : (Pig.IsInLoveCooldown() ? 1 : 0));
3615 auto & Sheep =
static_cast<const cSheep &
>(a_Mob);
3617 a_Pkt.
WriteBEInt8(Sheep.IsBaby() ? -1 : (Sheep.IsInLoveCooldown() ? 1 : 0));
3620 Byte SheepMetadata = 0;
3621 SheepMetadata =
static_cast<Byte>(Sheep.GetFurColor());
3622 if (Sheep.IsSheared())
3624 SheepMetadata |= 0x10;
3642 auto & Slime =
static_cast<const cSlime &
>(a_Mob);
3658 auto & Villager =
static_cast<const cVillager &
>(a_Mob);
3668 auto & Witch =
static_cast<const cWitch &
>(a_Mob);
3676 auto & Wither =
static_cast<const cWither &
>(a_Mob);
3693 auto & Wolf =
static_cast<const cWolf &
>(a_Mob);
3694 Byte WolfStatus = 0;
3695 if (Wolf.IsSitting())
3724 auto & Zombie =
static_cast<const cZombie &
>(a_Mob);
3736 auto & ZombiePigman =
static_cast<const cZombiePigman &
>(a_Mob);
3738 a_Pkt.
WriteBEInt8(ZombiePigman.IsBaby() ? 1 : -1);
3744 auto & ZombieVillager =
reinterpret_cast<const cZombieVillager &
>(a_Mob);
3746 a_Pkt.
WriteBEInt8(ZombieVillager.IsBaby() ? 1 : -1);
3750 a_Pkt.
WriteBEUInt8((ZombieVillager.ConversionTime() == -1) ? 0 : 1);
3771 ASSERT(!
"cProtocol_1_8::WriteMobMetadata: received unimplemented type");
3790 default:
UNREACHABLE(
"cProtocol_1_8::WriteMobMetadata: received mob of invalid type");
3814 FMT_STRING(
"Incoming data, {0} (0x{0:x}) unparsed bytes already present in buffer:\n{1}\n"),
3821 FMT_STRING(
"Incoming data: {0} (0x{0:x}) bytes: \n{1}\n"),
3827 if (!a_Buffer.
Write(a_Data.data(), a_Data.size()))
3864 ASSERT(PacketLen > NumBytesRead);
3865 PacketLen -= NumBytesRead;
3867 if (UncompressedSize > 0)
3874 const auto Uncompressed = UncompressedData.
GetView();
3878 VERIFY(bb.
Write(Uncompressed.data(), Uncompressed.size()));
3907 FMT_STRING(
"There are {0} (0x{0:x}) bytes of non-parse-able data left in the buffer:\n{1}"),
3924 case Type::etEnderCrystal:
return 51;
3925 case Type::etPickup:
return 2;
3926 case Type::etFallingBlock:
return 70;
3927 case Type::etMinecart:
return 10;
3928 case Type::etBoat:
return 1;
3929 case Type::etTNT:
return 50;
3930 case Type::etProjectile:
3935 switch (Projectile.GetProjectileKind())
3937 case PType::pkArrow:
return 60;
3938 case PType::pkSnowball:
return 61;
3939 case PType::pkEgg:
return 62;
3940 case PType::pkGhastFireball:
return 63;
3941 case PType::pkFireCharge:
return 64;
3942 case PType::pkEnderPearl:
return 65;
3943 case PType::pkExpBottle:
return 75;
3944 case PType::pkSplashPotion:
return 73;
3945 case PType::pkFirework:
return 76;
3946 case PType::pkWitherSkull:
return 66;
3951 case Type::etFloater:
return 90;
3952 case Type::etItemFrame:
return 71;
3953 case Type::etLeashKnot:
return 77;
3956 case Type::etEntity:
3957 case Type::etPlayer:
3958 case Type::etMonster:
3959 case Type::etExpOrb:
3960 case Type::etPainting:
break;
3971 static const std::unordered_map<AString, int> ParticleMap
3975 {
"largeexplode", 1 },
3976 {
"hugeexplosion", 2 },
3977 {
"fireworksspark", 3 },
3982 {
"depthsuspend", 8 },
3984 {
"magiccrit", 10 },
3986 {
"largesmoke", 12 },
3988 {
"instantspell", 14 },
3990 {
"mobspellambient", 16 },
3991 {
"witchmagic", 17 },
3992 {
"dripwater", 18 },
3994 {
"angryvillager", 20 },
3995 {
"happyvillager", 21 },
3999 {
"enchantmenttable", 25 },
4005 {
"snowballpoof", 31 },
4006 {
"snowshovel", 32 },
4010 {
"iconcrack", 36 },
4011 {
"blockcrack", 37 },
4012 {
"blockdust", 38 },
4015 {
"mobappearance", 41 },
4016 {
"dragonbreath", 42 },
4018 {
"damageindicator", 44 },
4019 {
"sweepattack", 45 },
4020 {
"fallingdust", 46 },
4025 const auto ParticleName =
StrToLower(a_ParticleName);
4026 const auto FindResult = ParticleMap.find(ParticleName);
4027 if (FindResult == ParticleMap.end())
4029 LOGWARNING(
"Unknown particle: %s", a_ParticleName.c_str());
4030 ASSERT(!
"Unknown particle");
4034 return FindResult->second;
4043 switch (a_Statistic)
4158 ASSERT(PacketData.size() > 0);
4159 PacketData.resize(PacketData.size() - 1);
4161 CreateHexDump(PacketDataHex, PacketData.data(), PacketData.size(), 16);
4163 FMT_STRING(
"Next incoming packet is type {0} (0x{0:x}), length {1} (0x{1:x}) at state {2}. Payload:\n{3}\n"),
4178 Packet.resize(Packet.size() - 1);
4181 LOGD(
"Packet contents:\n%s", Out.c_str());
4197 LOGWARNING(
"Protocol 1.8: Wrong number of bytes read for packet 0x%x, state %d. Read %zu bytes, packet contained %u bytes",
4205 FMT_STRING(
"^^^^^^ Wrong number of bytes read for this packet (exp 1 left, got {} left) ^^^^^^\n\n\n"),
4211 ASSERT(!
"Read wrong number of bytes!");
4230 Checksum.
Update(
reinterpret_cast<const Byte *
>(ServerID.c_str()), ServerID.length());
4231 Checksum.
Update(a_Key, 16);
@ E_BLOCK_STANDING_BANNER
@ E_BLOCK_ENCHANTMENT_TABLE
std::vector< sSetBlock > sSetBlockVector
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
@ ZombieVillagerCureFinishes
@ MinecartSpawnerDelayResets
@ EntityGetsMagicalCriticalHit
eDimension
Dimension of a world.
eClickAction
Individual actions sent in the WindowClick packet.
@ caLeftClickOutsideHoldNothing
@ caRightClickOutsideHoldNothing
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
std::chrono::duration< signed long long int, cTickTime::period > cTickTimeLong
#define ARRAYCOUNT(X)
Evaluates to the number of elements in an array (compile-time!)
std::basic_string_view< std::byte > ContiguousByteBufferView
std::basic_string< std::byte > ContiguousByteBuffer
void LOGERROR(std::string_view a_Format, const Args &... args)
void LOGWARNING(std::string_view a_Format, const Args &... args)
void LOG(std::string_view a_Format, const Args &... args)
void FLOGERROR(std::string_view a_Format, const Args &... args)
bool g_ShouldLogCommOut
If set to true, the protocols will log each player's outgoing (S->C) communication to a per-connectio...
bool g_ShouldLogCommIn
If set to true, the protocols will log each player's incoming (C->S) communication to a per-connectio...
eMonsterType
Identifies individual monster type.
#define HANDLE_PACKET_READ(ByteBuf, Proc, Type, Var)
#define HANDLE_READ(ByteBuf, Proc, Type, Var)
Macros used to read packets more easily.
static const UInt32 CompressionThreshold
@ InteractWithBrewingstand
@ InteractWithCraftingTable
AString StrToLower(const AString &s)
Returns a lower-cased copy of the string.
bool SplitZeroTerminatedStrings(const AString &a_Strings, AStringVector &a_Output)
Splits a string that has embedded \0 characters, on those characters.
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...
std::vector< AString > AStringVector
AString SerializeSingleValueJsonObject(const AString &a_Key, const AString &a_Value)
Creates a Json string representing an object with the specified single value.
AString WriteFastString(const Json::Value &a_Root)
bool ParseString(const AString &a_JsonStr, Json::Value &a_Root, AString *a_ErrorMsg)
Utilities to allow casting a cWorld to one of its interfaces without including World....
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...
bool CallHookServerPing(cClientHandle &a_ClientHandle, AString &a_ServerDescription, int &a_OnlinePlayersCount, int &a_MaxPlayersCount, AString &a_Favicon)
BLOCKTYPE GetBlockType() const
An object that can store incoming bytes and lets its clients read the bytes sequentially The bytes ar...
size_t GetUsedSpace(void) const
Returns the number of bytes that are currently in the ringbuffer.
bool SkipRead(size_t a_Count)
Skips reading by a_Count bytes; returns false if not enough bytes in the ringbuffer.
bool CanReadBytes(size_t a_Count) const
Returns true if the specified amount of bytes are available for reading.
void CommitRead(void)
Removes the bytes that have been read from the ringbuffer.
void ReadAll(ContiguousByteBuffer &a_Data)
Reads all available data into a_Data.
bool ReadUUID(cUUID &a_Value)
bool ReadToByteBuffer(cByteBuffer &a_Dst, size_t a_NumBytes)
Reads the specified number of bytes and writes it into the destinatio bytebuffer.
size_t GetReadableSpace(void) const
Returns the number of bytes that are currently available for reading (may be less than UsedSpace due ...
bool ReadVarInt(T &a_Value)
Reads VarInt, assigns it to anything that can be assigned from an UInt64 (unsigned short,...
bool ReadXYZPosition64(int &a_BlockX, int &a_BlockY, int &a_BlockZ)
bool WriteVarInt32(UInt32 a_Value)
static size_t GetVarIntSize(UInt32 a_Value)
Gets the number of bytes that are needed to represent the given VarInt.
bool ReadVarUTF8String(AString &a_Value)
bool ReadSome(ContiguousByteBuffer &a_String, size_t a_Count)
Reads a_Count bytes into a_String; returns true if successful.
void ResetRead(void)
Restarts next reading operation at the start of the ringbuffer.
bool Write(const void *a_Bytes, size_t a_Count)
Writes the bytes specified to the ringbuffer.
static bool CanBEInt8Represent(int a_Value)
Returns if the given value can fit in a protocol big-endian 8 bit integer.
Compression::Result Compress()
ContiguousByteBufferView GetView() const
void ReadFrom(cByteBuffer &Buffer)
void ReadFrom(cByteBuffer &Buffer, size_t Size)
Compression::Result Extract(size_t UncompressedSize)
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 HandleCommandBlockEntityChange(UInt32 a_EntityID, const AString &a_NewCommand)
Called when the protocol receives a message, indicating that the player set a new command in the comm...
void SetViewDistance(int a_ViewDistance)
Sets the maximal view distance.
void SetUsername(AString &&a_Username)
void HandleEnchantItem(UInt8 a_WindowID, UInt8 a_Enchantment)
Called when the player enchants an Item in the Enchanting table UI.
void Kick(const AString &a_Reason)
void HandleChat(const AString &a_Message)
Called when the protocol detects a chat packet.
void ForgeAugmentServerListPing(Json::Value &a_Response)
Add the Forge mod list to the server ping response.
void SetClientBrand(const AString &a_ClientBrand)
Called by the protocol when it receives the MC|Brand plugin message.
void HandleResourcePack(UInt8 a_Status)
void HandleAnvilItemName(const AString &a_ItemName)
Called when the protocol receives a MC|ItemName plugin message, indicating that the player named an i...
void PacketUnknown(UInt32 a_PacketType)
void HandleWindowClick(UInt8 a_WindowID, Int16 a_SlotNum, eClickAction a_ClickAction, const cItem &a_HeldItem)
short GetPing(void) const
void HandleLeaveBed()
Handles a player exiting his bed.
void HandleKeepAlive(UInt32 a_KeepAliveID)
void PacketError(UInt32 a_PacketType)
void SendPluginMessage(const AString &a_Channel, std::string_view a_Message)
void HandlePlayerLook(float a_Rotation, float a_Pitch, bool a_IsOnGround)
void HandleRightClick(Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_Cursor, bool a_UsedMainHand)
void HandlePluginMessage(const AString &a_Channel, ContiguousByteBufferView a_Message)
bool HandleHandshake(const AString &a_Username)
Called when the protocol handshake has been received (for protocol versions that support it; otherwis...
const cUUID & GetUUID(void) const
Returns the player's UUID, as used by the protocol.
void ProxyInit(const AString &a_IPString, const cUUID &a_UUID)
Function to mark bungee / proxy connection on this client, and to add proxy-related data.
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 SetIsForgeClient()
Mark a client connection as using Forge.
void HandleSteerVehicle(float Forward, float Sideways)
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.
const AString & GetIPString(void) const
void HandleTabCompletion(const AString &a_Text)
void HandlePlayerAbilities(bool a_IsFlying, float FlyingSpeed, float WalkingSpeed)
void HandleNPCTrade(int a_SlotNum)
Called when the protocol receives a MC|TrSel packet, indicating that the player used a trade in the N...
void HandleSpectate(const cUUID &a_PlayerUUID)
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...
void HandleWindowClose(UInt8 a_WindowID)
void HandleCrouch(bool a_IsCrouching)
Handles a player sneaking or unsneaking.
cPlayer * GetPlayer(void)
void PacketBufferFull(void)
void HandleSlotSelected(Int16 a_SlotNum)
void HandlePlayerMoveLook(Vector3d a_Pos, float a_Rotation, float a_Pitch, bool a_IsOnGround)
bool HandleLogin()
Called when the protocol has finished logging the user in.
void HandleOpenHorseInventory()
Handles a player opening his inventory while riding a horse.
void SendData(ContiguousByteBufferView a_Data)
void HandleAnimation(bool a_SwingMainHand)
Called when the protocol receives a (hand swing) animation packet.
const Json::Value & GetProperties(void) const
void HandleCreativeInventory(Int16 a_SlotNum, const cItem &a_HeldItem, eClickAction a_ClickAction)
Called when the client clicks the creative inventory window.
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.
bool IsProjectile(void) const
virtual bool IsElytraFlying(void) const
virtual bool IsRclking(void) const
bool IsPlayer(void) const
double GetSpeedZ(void) const
virtual bool IsCrouched(void) const
float GetMaxHealth(void) const
double GetSpeedY(void) const
bool IsItemFrame(void) const
Vector3d GetLastSentPosition(void) const
Returns the last position we sent to all the clients.
double GetPosX(void) const
double GetPosZ(void) const
bool IsMinecart(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.
bool IsFallingBlock(void) const
bool IsFloater(void) const
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
cWorld * GetWorld(void) const
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.
cClientHandle * GetClientHandle(void) const
void AwardAchievement(CustomStatistic a_Ach)
Awards the player an achievement.
StatisticsManager & GetStatistics()
Return the associated statistic and achievement manager.
int GetCurrentXp(void)
Gets the current experience.
const cUUID & GetUUID(void) const
Returns the UUID that has been read from the client, or nil if not available.
const cItem & GetEquippedItem(void) const
float GetXpPercentage(void) const
Gets the experience bar percentage - XpP.
virtual bool CanFly(void) const
Returns wheter the player can fly or not.
double GetFlyingMaxSpeed(void) const
Gets the flying relative maximum speed.
int GetXpLevel(void) const
Gets the current level - XpLevel.
bool IsGameModeCreative(void) const
Returns true if the player is in Creative mode, either explicitly, or by inheriting from current worl...
void SetSkinParts(int a_Parts)
double GetNormalMaxSpeed(void) const
Gets the normal relative maximum speed.
bool IsGameModeSpectator(void) const
Returns true if the player is in Spectator mode, either explicitly, or by inheriting from current wor...
bool IsFlying(void) const
Returns true if the player is currently flying.
int GetFoodLevel(void) const
AString GetPlayerListName(void) const
Returns the name that is used in the playerlist.
eGameMode GetEffectiveGameMode(void) const
Returns the current effective gamemode (inherited gamemode is resolved before returning)
double GetFoodSaturationLevel(void) const
eKind
The kind of the projectile.
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
void Empty(void)
Empties the item and frees up any dynamic storage used by the internals.
cFireworkItem m_FireworkItem
This class bridges a vector of cItem for safe access via Lua.
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
void Init(const Byte a_Key[16], const Byte a_IV[16])
Initializes the decryptor with the specified Key / IV.
void ProcessData(std::byte *a_EncryptedIn, size_t a_Length)
Decrypts a_Length bytes of the encrypted data in-place; produces a_Length output bytes.
void ProcessData(std::byte *a_PlainIn, size_t a_Length)
Encrypts a_Length bytes of the plain data in-place; produces a_Length output bytes.
void Init(const Byte a_Key[16], const Byte a_IV[16])
Initializes the decryptor with the specified Key / IV.
Encapsulates an RSA private key used in PKI cryptography.
int Decrypt(ContiguousByteBufferView a_EncryptedData, Byte *a_DecryptedData, size_t a_DecryptedMaxLength)
Decrypts the data using RSAES-PKCS#1 algorithm.
Calculates a SHA1 checksum for data stream.
void Update(const Byte *a_Data, size_t a_Length)
Adds the specified data to the checksum.
void Finalize(Checksum &a_Output)
Calculates and returns the final checksum.
static void DigestToHex(const Checksum &a_Digest, AString &a_Out)
Converts a SHA1 digest into hex.
static void DigestToJava(const Checksum &a_Digest, AString &a_Out)
Converts a raw 160-bit SHA1 digest into a Java Hex representation According to http://wiki....
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
RAII for cCriticalSection - locks the CS on creation, unlocks on destruction.
void Flush()
Flushes all the bufferef output into the file (only when writing)
static bool CreateFolder(const AString &a_FolderPath)
Creates a new folder with the specified name.
bool Open(const AString &iFileName, eMode iMode)
int Write(const void *a_Buffer, size_t a_NumBytes)
Writes up to a_NumBytes bytes from a_Buffer, returns the number of bytes actually written,...
Composes an individual packet in the protocol's m_OutPacketBuffer; sends it just before being destruc...
cProtocol::ePacketType GetPacketType() const
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)
static AString PacketTypeToStr(cProtocol::ePacketType a_PacketType)
Returns the human-readable representation of the packet type.
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 WriteFPInt(double a_Value)
Writes the double value as a 27:5 fixed-point integer.
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 WriteBEInt64(Int64 a_Value)
void WriteByteAngle(double a_Angle)
Writes the specified angle using a single byte.
void WriteBEInt8(Int8 a_Value)
cCriticalSection m_CSPacket
Provides synchronization for sending the entire packet at once.
cByteBuffer m_OutPacketLenBuffer
Buffer for composing packet length (so that each cPacketizer instance doesn't allocate a new cPacketB...
ePacketType
Logical types of outgoing packets.
@ pktTabCompletionResults
@ pktPlayerListHeaderFooter
@ pktDisconnectDuringGame
@ pktDisconnectDuringLogin
Version
The protocol version number, received from the client in the Handshake packet.
cByteBuffer m_OutPacketBuffer
Buffer for composing the outgoing packets, through cPacketizer.
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 WriteEntityProperties(cPacketizer &a_Pkt, const cEntity &a_Entity) const
Writes the entity properties for the specified entity, including the Count field.
virtual void SendPlayerListRemovePlayer(const cPlayer &a_Player) override
void AddReceivedData(cByteBuffer &a_Buffer, ContiguousByteBufferView a_Data)
Adds the received (unencrypted) data to m_ReceivedData, parses complete packets.
virtual void ParseItemMetadata(cItem &a_Item, ContiguousByteBufferView a_Metadata) const
Parses item metadata as read by ReadItem(), into the item enchantments.
virtual void HandlePacketEntityAction(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketPlayer(cByteBuffer &a_ByteBuffer)
virtual void SendEntityVelocity(const cEntity &a_Entity) override
virtual void SendPlayerListHeaderFooter(const cCompositeChat &a_Header, const cCompositeChat &a_Footer) override
virtual void SendUpdateBlockEntity(cBlockEntity &a_BlockEntity) override
virtual void HandlePacketUpdateSign(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketStatusPing(cByteBuffer &a_ByteBuffer)
virtual void SendEntitySpawn(const cEntity &a_Entity, const UInt8 a_ObjectType, const Int32 a_ObjectData)
Sends the entity type and entity-dependent data required for the entity to initially spawn.
virtual void HandlePacketLoginEncryptionResponse(cByteBuffer &a_ByteBuffer)
virtual void DataPrepared(ContiguousByteBuffer &a_Data) override
Called by cClientHandle to finalise a buffer of prepared data before they are sent to the client.
virtual void SendGameMode(eGameMode a_GameMode) override
virtual void HandlePacketEnchantItem(cByteBuffer &a_ByteBuffer)
virtual void SendTabCompletionResults(const AStringVector &a_Results) override
virtual UInt32 GetProtocolMobType(eMonsterType a_MobType) const
Converts eMonsterType to protocol-specific mob types.
virtual void SendTimeUpdate(cTickTimeLong a_WorldAge, cTickTimeLong a_WorldDate, bool a_DoDaylightCycle) override
virtual void SendPlayerListUpdateGameMode(const cPlayer &a_Player) override
virtual void SendPlayerListAddPlayer(const cPlayer &a_Player) override
virtual void WriteEntityMetadata(cPacketizer &a_Pkt, const cEntity &a_Entity) const
Writes the metadata for the specified entity, not including the terminating 0x7f.
void StartEncryption(const Byte *a_Key)
virtual void SendRemoveEntityEffect(const cEntity &a_Entity, int a_EffectID) override
virtual void HandlePacketUseEntity(cByteBuffer &a_ByteBuffer)
virtual void SendParticleEffect(const AString &a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount) override
virtual void SendScoreUpdate(const AString &a_Objective, const AString &a_Player, cObjective::Score a_Score, Byte a_Mode) override
virtual void SendExperienceOrb(const cExpOrb &a_ExpOrb) override
virtual unsigned char GetProtocolEntityAnimation(EntityAnimation a_Animation) const
Converts an animation into an ID suitable for use with the Entity Animation packet.
virtual void SendResourcePack(const AString &a_ResourcePackUrl) override
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 HandlePacketClientSettings(cByteBuffer &a_ByteBuffer)
virtual void SendWholeInventory(const cWindow &a_Window) override
virtual void SendPlayerPosition(void) override
virtual void SendBlockAction(Vector3i a_BlockPos, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) override
virtual void SendSetRawSubTitle(const AString &a_SubTitle) override
virtual void HandlePacketLoginStart(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketPlayerPos(cByteBuffer &a_ByteBuffer)
virtual void SendExperience(void) override
virtual void SendEntityPosition(const cEntity &a_Entity) override
virtual void SendExplosion(Vector3f a_Position, float a_Power) 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 SendRespawn(eDimension a_Dimension) override
virtual void SendUnlockRecipe(UInt32 a_RecipeID) override
virtual void SendScoreboardObjective(const AString &a_Name, const AString &a_DisplayName, Byte a_Mode) override
virtual void SendEntityProperties(const cEntity &a_Entity) override
virtual void HandlePacketCreativeInventoryAction(cByteBuffer &a_ByteBuffer)
virtual UInt32 GetPacketID(ePacketType a_Packet) const override
Get the packet ID for a given packet.
virtual void SendPluginMessage(const AString &a_Channel, ContiguousByteBufferView a_Message) override
virtual void SendInventorySlot(char a_WindowID, short a_SlotNum, const cItem &a_Item) override
virtual void SendSetRawTitle(const AString &a_Title) override
virtual void SendUnleashEntity(const cEntity &a_Entity) override
virtual void SendSoundParticleEffect(const EffectID a_EffectID, Vector3i a_Origin, int a_Data) override
virtual void SendInitRecipes(UInt32 a_RecipeID) override
virtual void HandlePacketWindowClose(cByteBuffer &a_ByteBuffer)
virtual void SendSetTitle(const cCompositeChat &a_Title) override
virtual void SendBlockBreakAnim(UInt32 a_EntityID, Vector3i a_BlockPos, char a_Stage) override
virtual void HandleVanillaPluginMessage(cByteBuffer &a_ByteBuffer, std::string_view a_Channel)
Parses Vanilla plugin messages into specific ClientHandle calls.
virtual void SendChat(const AString &a_Message, eChatType a_Type) override
virtual void SendBossBarUpdateHealth(UInt32 a_UniqueID, float a_FractionFilled) override
virtual void HandlePacketStatusRequest(cByteBuffer &a_ByteBuffer)
virtual void SendEntityMetadata(const cEntity &a_Entity) override
virtual void SendEntityEffect(const cEntity &a_Entity, int a_EffectID, int a_Amplifier, int a_Duration) override
virtual void HandlePacketPluginMessage(cByteBuffer &a_ByteBuffer)
cAesCfb128Decryptor m_Decryptor
cFile m_CommLogFile
The logfile where the comm is logged, when g_ShouldLogComm is true.
virtual void SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockVector &a_Changes) override
virtual void HandlePacketPlayerAbilities(cByteBuffer &a_ByteBuffer)
virtual void SendUnloadChunk(int a_ChunkX, int a_ChunkZ) override
virtual void WriteMobMetadata(cPacketizer &a_Pkt, const cMonster &a_Mob) const
Writes the mob-specific metadata for the specified mob.
virtual void SendDisconnect(const AString &a_Reason) override
virtual void SendWindowClose(const cWindow &a_Window) override
virtual void SendDisplayObjective(const AString &a_Objective, cScoreboard::eDisplaySlot a_Display) override
virtual void SendDestroyEntity(const cEntity &a_Entity) override
virtual void SendPlayerPermissionLevel(void) override
virtual void SendHealth(void) override
virtual void WriteItem(cPacketizer &a_Pkt, const cItem &a_Item) const
Writes the item data into a packet.
virtual void SendSetSubTitle(const cCompositeChat &a_SubTitle) override
virtual void SendWindowProperty(const cWindow &a_Window, size_t a_Property, short a_Value) override
virtual void SendHeldItemChange(int a_ItemIndex) override
virtual void SendEntityHeadLook(const cEntity &a_Entity) override
virtual void SendPlayerListUpdatePing() override
virtual void SendLogin(const cPlayer &a_Player, const cWorld &a_World) override
virtual void SendPlayerMoveLook(void) override
cProtocol_1_8_0(cClientHandle *a_Client, const AString &a_ServerAddress, State a_State)
virtual void SendBossBarRemove(UInt32 a_UniqueID) override
virtual void SendCollectEntity(const cEntity &a_Collected, const cEntity &a_Collector, unsigned a_Count) override
virtual void SendBlockChange(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override
virtual void SendPlayerAbilities(void) override
virtual void SendResetTitle(void) override
virtual void HandlePacketChatMessage(cByteBuffer &a_ByteBuffer)
State m_State
State of the protocol.
virtual UInt8 GetProtocolEntityType(const cEntity &a_Entity) const
Converts an entity to a protocol-specific entity type.
virtual void HandlePacketKeepAlive(cByteBuffer &a_ByteBuffer)
virtual void SendLoginSuccess(void) override
virtual void SendBossBarUpdateTitle(UInt32 a_UniqueID, const cCompositeChat &a_Title) override
virtual void HandlePacketResourcePackStatus(cByteBuffer &a_ByteBuffer)
virtual void SendDetachEntity(const cEntity &a_Entity, const cEntity &a_PreviousVehicle) override
virtual void HandlePacketBlockPlace(cByteBuffer &a_ByteBuffer)
static const char * GetProtocolStatisticName(CustomStatistic a_Statistic)
Converts a statistic to a protocol-specific string.
virtual void SendMapData(const cMap &a_Map, int a_DataStartX, int a_DataStartY) override
virtual void SendTitleTimes(int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks) override
virtual int GetProtocolParticleID(const AString &a_ParticleName) const
The 1.8 protocol use a particle id instead of a string.
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.
virtual void HandlePacketPlayerPosLook(cByteBuffer &a_ByteBuffer)
static eBlockFace FaceIntToBlockFace(Int32 a_FaceInt)
Converts the BlockFace received by the protocol into eBlockFace constants.
virtual void HandlePacketBlockDig(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketPlayerLook(cByteBuffer &a_ByteBuffer)
CircularBufferCompressor m_Compressor
virtual void SendEntityAnimation(const cEntity &a_Entity, EntityAnimation a_Animation) override
virtual void SendKeepAlive(UInt32 a_PingID) override
virtual Version GetProtocolVersion() const override
Returns the protocol version.
virtual void SendCameraSetTo(const cEntity &a_Entity) override
virtual signed char GetProtocolEntityStatus(EntityAnimation a_Animation) const
Converts an animation into an ID suitable for use with the Entity Status packet.
virtual void HandlePacketWindowClick(cByteBuffer &a_ByteBuffer)
virtual void SendWindowOpen(const cWindow &a_Window) override
virtual void SendHideTitle(void) override
static void CompressPacket(CircularBufferCompressor &a_Packet, ContiguousByteBuffer &a_Compressed)
Compress the packet.
virtual void SendPlayerSpawn(const cPlayer &a_Player) override
cAesCfb128Encryptor m_Encryptor
virtual void SendPlayerListUpdateDisplayName(const cPlayer &a_Player, const AString &a_CustomName) override
virtual void SendBossBarUpdateFlags(UInt32 a_UniqueID, bool a_DarkenSky, bool a_PlayEndMusic, bool a_CreateFog) override
virtual void DataReceived(cByteBuffer &a_Buffer, ContiguousByteBuffer &a_Data) override
Called by cClientHandle to process data, when the client sends some.
virtual void SendAttachEntity(const cEntity &a_Entity, const cEntity &a_Vehicle) override
virtual void SendSpawnEntity(const cEntity &a_Entity) override
virtual void HandlePacketSteerVehicle(cByteBuffer &a_ByteBuffer)
virtual void SendEntityLook(const cEntity &a_Entity) override
virtual void SendPacket(cPacketizer &a_Packet) override
Sends the packet to the client.
CircularBufferExtractor m_Extractor
virtual void SendSpawnMob(const cMonster &a_Mob) override
virtual void SendThunderbolt(Vector3i a_BlockPos) override
virtual void HandlePacketClientStatus(cByteBuffer &a_ByteBuffer)
virtual void SendStatistics(const StatisticsManager &a_Manager) override
virtual void HandlePacketSlotSelect(cByteBuffer &a_ByteBuffer)
virtual void SendChatRaw(const AString &a_MessageRaw, eChatType a_Type) override
virtual void SendEditSign(Vector3i a_BlockPos) override
Request the client to open up the sign editor for the sign (1.6+)
virtual void HandlePacketAnimation(cByteBuffer &a_ByteBuffer)
virtual bool HandlePacket(cByteBuffer &a_ByteBuffer, UInt32 a_PacketType)
Reads and handles the packet.
virtual void SendWeather(eWeather a_Weather) override
virtual void SendLeashEntity(const cEntity &a_Entity, const cEntity &a_EntityLeashedTo) override
virtual void SendPaintingSpawn(const cPainting &a_Painting) override
virtual void SendUpdateSign(Vector3i a_BlockPos, const AString &a_Line1, const AString &a_Line2, const AString &a_Line3, const AString &a_Line4) override
virtual void HandlePacketTabComplete(cByteBuffer &a_ByteBuffer)
virtual void SendEntityEquipment(const cEntity &a_Entity, short a_SlotNum, const cItem &a_Item) override
virtual void HandlePacketSpectate(cByteBuffer &a_ByteBuffer)
virtual void SendChunkData(ContiguousByteBufferView a_ChunkData) override
static AString GetVersionTextFromInt(cProtocol::Version a_ProtocolVersion)
Translates protocol version number into protocol version text: 49 -> "1.4.4".
cServer * GetServer(void)
cPluginManager * GetPluginManager(void)
ContiguousByteBufferView GetPublicKeyDER(void) const
size_t GetMaxPlayers(void) const
const AString & GetDescription(void) const
const AString & GetServerID(void) const
size_t GetNumPlayers(void) const
cRsaPrivateKey & GetPrivateKey(void)
bool IsHardcore(void) const
const AString & GetFaviconData(void) const
Returns base64 encoded favicon data (obtained from favicon.png)
Class that manages the statistics and achievements of a single player.
std::unordered_map< CustomStatistic, StatValue > Custom
ContiguousByteBufferView GetView() const
Returns a view (of type std::byte) of the internal store.
void GetSlots(cPlayer &a_Player, cItems &a_Slots) const
Fills a_Slots with the slots read from m_SlotAreas[], for the specified player.
int GetNumNonInventorySlots(void) const
Returns the number of slots, excluding the player's inventory (used for network protocols)
int GetNumSlots(void) const
Returns the total number of slots.
char GetWindowID(void) const
const AString & GetWindowTitle() const
int GetWindowType(void) const
const AString GetWindowTypeName(void) const
Returns the textual representation of the window's type, such as "minecraft:chest".
bool FromString(const AString &a_StringUUID)
Tries to interpret the string as a short or long form UUID and assign from it.
AString ToLongString() const
Converts the UUID to a long form string (i.e.
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 AddByte(const AString &a_Name, unsigned char a_Value)
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.