15 #include "../Entities/Boat.h"
16 #include "../Entities/EnderCrystal.h"
17 #include "../Entities/Minecart.h"
18 #include "../Entities/Pickup.h"
19 #include "../Entities/Player.h"
20 #include "../Entities/ItemFrame.h"
21 #include "../Entities/ArrowEntity.h"
22 #include "../Entities/FireworkEntity.h"
23 #include "../Entities/SplashPotionEntity.h"
25 #include "../Mobs/IncludeAllMonsters.h"
28 #include "../Server.h"
29 #include "../ClientHandle.h"
30 #include "../CraftingRecipes.h"
31 #include "../Bindings/PluginManager.h"
32 #include "../JsonUtils.h"
45 #pragma clang diagnostic push
46 #pragma clang diagnostic ignored "-Wduplicate-enum"
96 _FIREBALL_NEXT = _ENTITY_NEXT,
106 _HANGING_NEXT = _ENTITY_NEXT,
143 _AMBIENT_NEXT = _INSENTIENT_NEXT,
149 _CREATURE_NEXT = _INSENTIENT_NEXT,
159 _ANIMAL_NEXT = _AGEABLE_NEXT,
164 _ABSTRACT_HORSE_NEXT,
206 _GOLEM_NEXT = _CREATURE_NEXT,
217 _MONSTER_NEXT = _CREATURE_NEXT,
273 _FLYING_NEXT = _INSENTIENT_NEXT,
303 #pragma clang diagnostic pop
351 auto & Player =
static_cast<const cPlayer &
>(a_Entity);
362 a_Pkt.
WriteBEFloat(
static_cast<float>(Player.GetHealth()));
402 const cItem & MinecartContent = RideableMinecart.GetContent();
403 if (!MinecartContent.
IsEmpty())
432 switch (Projectile.GetProjectileKind())
472 auto & Boat =
static_cast<const cBoat &
>(a_Entity);
492 a_Pkt.
WriteBool(Boat.IsRightPaddleUsed());
496 a_Pkt.
WriteBool(Boat.IsLeftPaddleUsed());
503 auto & Frame =
static_cast<const cItemFrame &
>(a_Entity);
515 const auto & EnderCrystal =
static_cast<const cEnderCrystal &
>(a_Entity);
516 if (EnderCrystal.DisplaysBeam())
525 a_Pkt.
WriteBool(EnderCrystal.ShowsBottom());
565 auto & Bat =
static_cast<const cBat &
>(a_Mob);
584 auto & Cow =
static_cast<const cCow &
>(a_Mob);
611 auto & Enderman =
static_cast<const cEnderman &
>(a_Mob);
615 Carried |=
static_cast<UInt32>(Enderman.GetCarriedBlock() << 4);
616 Carried |= Enderman.GetCarriedMeta();
627 auto & Ghast =
static_cast<const cGhast &
>(a_Mob);
639 auto & Horse =
static_cast<const cHorse &
>(a_Mob);
645 if (Horse.IsSaddled())
649 if (Horse.IsChested())
653 if (Horse.IsEating())
657 if (Horse.IsRearing())
661 if (Horse.IsMthOpen())
678 Appearance = Horse.GetHorseColor();
679 Appearance |= Horse.GetHorseStyle() << 8;
694 auto & MagmaCube =
static_cast<const cMagmaCube &
>(a_Mob);
703 auto & Ocelot =
static_cast<const cOcelot &
>(a_Mob);
709 Int8 OcelotStatus = 0;
710 if (Ocelot.IsSitting())
731 auto & Pig =
static_cast<const cPig &
>(a_Mob);
760 auto & Sheep =
static_cast<const cSheep &
>(a_Mob);
768 Int8 SheepMetadata = 0;
769 SheepMetadata =
static_cast<Int8>(Sheep.GetFurColor());
770 if (Sheep.IsSheared())
772 SheepMetadata |= 0x10;
780 auto & Skeleton =
static_cast<const cSkeleton &
>(a_Mob);
783 a_Pkt.
WriteBEUInt8(Skeleton.IsChargingBow() ? 0x01 : 0x00);
787 a_Pkt.
WriteBool(Skeleton.IsChargingBow());
793 auto & Slime =
static_cast<const cSlime &
>(a_Mob);
802 auto & Villager =
static_cast<const cVillager &
>(a_Mob);
815 auto & Witch =
static_cast<const cWitch &
>(a_Mob);
824 auto & Wither =
static_cast<const cWither &
>(a_Mob);
835 auto & Wolf =
static_cast<const cWolf &
>(a_Mob);
841 if (Wolf.IsSitting())
874 auto & Zombie =
static_cast<const cZombie &
>(a_Mob);
889 auto & ZombiePigman =
static_cast<const cZombiePigman &
>(a_Mob);
898 auto & ZombieVillager =
reinterpret_cast<const cZombieVillager &
>(a_Mob);
901 a_Pkt.
WriteBool(ZombieVillager.IsBaby());
962 ASSERT(!
"cProtocol_1_12::WriteMobMetadata: received unimplemented type");
975 default:
UNREACHABLE(
"cProtocol_1_12::WriteMobMetadata: received mob of invalid type");
1029 HANDLE_READ(a_ByteBuffer, ReadBool,
bool, MakeAll);
1031 if (CuberiteRecipeId.has_value())
1064 switch (a_Animation)
1105 switch (a_PacketType)
1115 switch (a_PacketType)
1125 switch (a_PacketType)
1235 switch (a_PacketType)
1245 switch (a_PacketType)
1255 switch (a_PacketType)
1319 (KeepAliveID <= std::numeric_limits<UInt32>::max()) &&
1337 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);
1354 if (ProtocolRecipeId.has_value())
1374 if (!ProtocolRecipeId.has_value())
1383 if (a_RecipeID == 0)
void LOGWARNING(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.
@ AREA_EFFECT_CLOUD_RADIUS
@ AREA_EFFECT_CLOUD_PARTICLE_PARAMETER2
@ ARMOR_STAND_LEFT_ARM_ROTATION
@ SHULKER_FACING_DIRECTION
@ MINECART_COMMAND_BLOCK_LAST_OUTPUT
@ AREA_EFFECT_CLOUD_PARTICLE_ID
@ MINECART_FURNACE_POWERED
@ LIVING_POTION_EFFECT_COLOR
@ ARMOR_STAND_RIGHT_ARM_ROTATION
@ AREA_EFFECT_CLOUD_COLOR
@ PLAYER_DISPLAYED_SKIN_PARTS
@ FIREWORK_BOOSTED_ENTITY_ID
@ AREA_EFFECT_CLOUD_PARTICLE_PARAMETER1
@ ENTITY_CUSTOM_NAME_VISIBLE
@ WITHER_THIRD_HEAD_TARGET
@ WITHER_INVULNERABLE_TIMER
@ BOAT_LEFT_PADDLE_TURNING
@ MINECART_SHAKING_MULTIPLIER
@ WITHER_FIRST_HEAD_TARGET
@ PLAYER_ADDITIONAL_HEARTHS
@ ARMOR_STAND_HEAD_ROTATION
@ LIVING_POTION_EFFECT_AMBIENT
@ MINECART_SHAKING_DIRECTION
@ ZOMBIE_VILLAGER_PROFESSION
@ WITHER_SECOND_HEAD_TARGET
@ SHULKER_ATTACHMENT_FALLING_BLOCK_POSITION
@ IRON_GOLEM_PLAYER_CREATED
@ ARMOR_STAND_BODY_ROTATION
@ ABSTRACT_SKELETON_ARMS_SWINGING
@ LIVING_NUMBER_OF_ARROWS
@ ZOMBIE_VILLAGER_CONVERTING
@ ENDER_CRYSTAL_BEAM_TARGET
@ MINECART_COMMAND_BLOCK_COMMAND
@ BOAT_RIGHT_PADDLE_TURNING
@ ENDER_DRAGON_DRAGON_PHASE
@ ARMOR_STAND_RIGHT_LEG_ROTATION
@ WITHER_SKULL_INVULNERABLE
@ PIG_TOTAL_CARROT_ON_A_STICK_BOOST
@ ARMOR_STAND_LEFT_LEG_ROTATION
@ ENDER_CRYSTAL_SHOW_BOTTOM
@ AREA_EFFECT_CLOUD_SINGLE_POINT_EFFECT
An object that can store incoming bytes and lets its clients read the bytes sequentially The bytes ar...
bool SkipRead(size_t a_Count)
Skips reading by a_Count bytes; returns false if not enough bytes in the ringbuffer.
size_t GetReadableSpace(void) const
Returns the number of bytes that are currently available for reading (may be less than UsedSpace due ...
void PacketUnknown(UInt32 a_PacketType)
void HandleKeepAlive(UInt32 a_KeepAliveID)
UInt32 GetProtocolVersion(void) const
Returns the protocol version number of the protocol that the client is talking.
cPlayer * GetPlayer(void)
void HandleCraftRecipe(UInt32 a_RecipeId)
Called when a recipe from the recipe book is selected.
bool IsCritical(void) const
Returns true if the arrow is set as critical.
virtual bool IsElytraFlying(void) const
virtual bool IsRclking(void) const
virtual bool IsCrouched(void) const
float GetMaxHealth(void) const
eEntityType GetEntityType(void) const
virtual bool IsOnFire(void) const
virtual bool IsInvisible(void) const
float GetHealth(void) const
Returns the health of this entity.
virtual bool IsSprinting(void) const
bool IsFueled(void) const
void SendMessageInfo(const AString &a_Message)
bool IsEmpty(void) const
Returns true if the item represents an empty stack - either the type is invalid, or count is zero.
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
Composes an individual packet in the protocol's m_OutPacketBuffer; sends it just before being destruc...
void WriteVarInt32(UInt32 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 WriteBEFloat(float a_Value)
void WriteString(const AString &a_Value)
void WriteBEUInt8(UInt8 a_Value)
void WriteBEInt64(Int64 a_Value)
void WriteBEInt8(Int8 a_Value)
ePacketType
Logical types of outgoing packets.
@ pktPlayerListHeaderFooter
Version
The protocol version number, received from the client in the Handshake packet.
virtual void HandlePacketResourcePackStatus(cByteBuffer &a_ByteBuffer) override
virtual signed char GetProtocolEntityStatus(EntityAnimation a_Animation) const override
Converts an animation into an ID suitable for use with the Entity Status packet.
virtual UInt32 GetProtocolMobType(eMonsterType a_MobType) const override
Converts eMonsterType to protocol-specific mob types.
virtual void HandlePacketBlockPlace(cByteBuffer &a_ByteBuffer) override
virtual void HandleCraftRecipe(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketAdvancementTab(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketCraftingBookData(cByteBuffer &a_ByteBuffer)
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 signed char GetProtocolEntityStatus(EntityAnimation a_Animation) const override
Converts an animation into an ID suitable for use with the Entity Status packet.
virtual UInt32 GetPacketID(ePacketType a_Packet) const override
Get the packet ID for a given packet.
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 UInt32 GetProtocolMobType(eMonsterType a_MobType) const override
Converts eMonsterType to protocol-specific mob types.
virtual bool HandlePacket(cByteBuffer &a_ByteBuffer, UInt32 a_PacketType) override
Reads and handles the packet.
virtual bool HandlePacket(cByteBuffer &a_ByteBuffer, UInt32 a_PacketType) override
Reads and handles the packet.
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 void HandlePacketKeepAlive(cByteBuffer &a_ByteBuffer) override
virtual Version GetProtocolVersion() const override
Returns the protocol version.
virtual void SendKeepAlive(UInt32 a_PingID) override
virtual void SendInitRecipes(UInt32 a_RecipeID) override
virtual void SendUnlockRecipe(UInt32 a_RecipeID) override
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 void HandlePacketLoginStart(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketCreativeInventoryAction(cByteBuffer &a_ByteBuffer)
virtual void HandlePacketWindowClose(cByteBuffer &a_ByteBuffer)
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 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 WriteItem(cPacketizer &a_Pkt, const cItem &a_Item) const override
Writes the item data into a packet.
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 HandlePacketEntityAction(cByteBuffer &a_ByteBuffer) override
virtual void HandlePacketPlayerPosLook(cByteBuffer &a_ByteBuffer) override
virtual void HandlePacketBoatSteer(cByteBuffer &a_ByteBuffer)
virtual void HandleConfirmTeleport(cByteBuffer &a_ByteBuffer)
@ METADATA_TYPE_OPTIONAL_POSITION
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
virtual UInt32 GetPacketID(ePacketType a_Packet) const override
Get the packet ID for a given packet.
std::optional< UInt32 > GetProtocolRecipeId(UInt32 a_RecipeId, UInt32 a_ProtocolVersion)
Translates the cuberite RecipeId to the protocol specific RecipeId.
std::optional< UInt32 > GetCuberiteRecipeId(UInt32 a_ProtocolRecipeId, UInt32 a_ProtocolVersion)
Translates the protocol specific RecipeId to the cuberite RecipeId.
cRecipeMapper * GetRecipeMapper(void)