14 #include "json/json.h"
17 #include "../Server.h"
18 #include "../ClientHandle.h"
19 #include "../JsonUtils.h"
21 #include "../WorldStorage/FastNBT.h"
23 #include "../Entities/Boat.h"
24 #include "../Entities/EnderCrystal.h"
25 #include "../Entities/ExpOrb.h"
26 #include "../Entities/Minecart.h"
27 #include "../Entities/FallingBlock.h"
28 #include "../Entities/Painting.h"
29 #include "../Entities/Pickup.h"
30 #include "../Entities/Player.h"
31 #include "../Entities/ItemFrame.h"
32 #include "../Entities/ArrowEntity.h"
33 #include "../Entities/FireworkEntity.h"
34 #include "../Entities/SplashPotionEntity.h"
36 #include "../Mobs/IncludeAllMonsters.h"
38 #include "../BlockEntities/BannerEntity.h"
39 #include "../BlockEntities/BeaconEntity.h"
40 #include "../BlockEntities/CommandBlockEntity.h"
41 #include "../BlockEntities/MobHeadEntity.h"
42 #include "../BlockEntities/MobSpawnerEntity.h"
43 #include "../BlockEntities/FlowerPotEntity.h"
45 #include "../Bindings/PluginManager.h"
58 #pragma clang diagnostic push
59 #pragma clang diagnostic ignored "-Wduplicate-enum"
109 _FIREBALL_NEXT = _ENTITY_NEXT,
118 _HANGING_NEXT = _ENTITY_NEXT,
155 _AMBIENT_NEXT = _INSENTIENT_NEXT,
161 _CREATURE_NEXT = _INSENTIENT_NEXT,
171 _ANIMAL_NEXT = _AGEABLE_NEXT,
206 _GOLEM_NEXT = _CREATURE_NEXT,
217 _MONSTER_NEXT = _CREATURE_NEXT,
261 _FLYING_NEXT = _INSENTIENT_NEXT,
291 #pragma clang diagnostic pop
385 auto & Player =
static_cast<const cPlayer &
>(a_Entity);
396 a_Pkt.
WriteBEFloat(
static_cast<float>(Player.GetHealth()));
436 const cItem & MinecartContent = RideableMinecart.GetContent();
437 if (!MinecartContent.
IsEmpty())
466 switch (Projectile.GetProjectileKind())
504 auto & Boat =
static_cast<const cBoat &
>(a_Entity);
524 a_Pkt.
WriteBool(Boat.IsRightPaddleUsed());
528 a_Pkt.
WriteBool(Boat.IsLeftPaddleUsed());
535 auto & Frame =
static_cast<const cItemFrame &
>(a_Entity);
547 const auto & EnderCrystal =
static_cast<const cEnderCrystal &
>(a_Entity);
550 a_Pkt.
WriteBool(EnderCrystal.DisplaysBeam());
551 if (EnderCrystal.DisplaysBeam())
557 a_Pkt.
WriteBool(EnderCrystal.ShowsBottom());
597 auto & Bat =
static_cast<const cBat &
>(a_Mob);
616 auto & Cow =
static_cast<const cCow &
>(a_Mob);
643 auto & Enderman =
static_cast<const cEnderman &
>(a_Mob);
647 Carried |=
static_cast<UInt32>(Enderman.GetCarriedBlock() << 4);
648 Carried |= Enderman.GetCarriedMeta();
659 auto & Ghast =
static_cast<const cGhast &
>(a_Mob);
668 auto & Horse =
static_cast<const cHorse &
>(a_Mob);
674 if (Horse.IsSaddled())
678 if (Horse.IsChested())
682 if (Horse.IsEating())
686 if (Horse.IsRearing())
690 if (Horse.IsMthOpen())
705 Appearance = Horse.GetHorseColor();
706 Appearance |= Horse.GetHorseStyle() << 8;
721 auto & MagmaCube =
static_cast<const cMagmaCube &
>(a_Mob);
730 auto & Ocelot =
static_cast<const cOcelot &
>(a_Mob);
740 auto & Pig =
static_cast<const cPig &
>(a_Mob);
768 auto & Sheep =
static_cast<const cSheep &
>(a_Mob);
776 Int8 SheepMetadata = 0;
777 SheepMetadata =
static_cast<Int8>(Sheep.GetFurColor());
778 if (Sheep.IsSheared())
780 SheepMetadata |= 0x10;
788 auto & Skeleton =
static_cast<const cSkeleton &
>(a_Mob);
791 a_Pkt.
WriteBEUInt8(Skeleton.IsChargingBow() ? 0x01 : 0x00);
795 a_Pkt.
WriteBool(Skeleton.IsChargingBow());
801 auto & Slime =
static_cast<const cSlime &
>(a_Mob);
810 auto & Villager =
static_cast<const cVillager &
>(a_Mob);
823 auto & Witch =
static_cast<const cWitch &
>(a_Mob);
832 auto & Wither =
static_cast<const cWither &
>(a_Mob);
851 auto & Wolf =
static_cast<const cWolf &
>(a_Mob);
857 if (Wolf.IsSitting())
890 auto & Zombie =
static_cast<const cZombie &
>(a_Mob);
907 auto & ZombiePigman =
static_cast<const cZombiePigman &
>(a_Mob);
916 auto & ZombieVillager =
reinterpret_cast<const cZombieVillager &
>(a_Mob);
919 a_Pkt.
WriteBool(ZombieVillager.IsBaby());
927 a_Pkt.
WriteBool(ZombieVillager.ConversionTime() != -1);
950 ASSERT(!
"cProtocol_1_10::WriteMobMetadata: received unimplemented type");
970 default:
UNREACHABLE(
"cProtocol_1_10::WriteMobMetadata: received mob of invalid type");
std::enable_if< std::is_arithmetic< T >::value, C >::type FloorC(T a_Value)
Floors a value, then casts it to C (an int by default).
eMonsterType
Identifies individual monster type.
#define HANDLE_READ(ByteBuf, Proc, Type, Var)
Macros used to read packets more easily.
@ ENDER_CRYSTAL_SHOW_BOTTOM
@ ARMOR_STAND_LEFT_LEG_ROTATION
@ ARMOR_STAND_BODY_ROTATION
@ MINECART_COMMAND_BLOCK_COMMAND
@ WITHER_SECOND_HEAD_TARGET
@ ARMOR_STAND_RIGHT_LEG_ROTATION
@ AREA_EFFECT_CLOUD_RADIUS
@ LIVING_NUMBER_OF_ARROWS
@ LIVING_POTION_EFFECT_COLOR
@ MINECART_FURNACE_POWERED
@ PLAYER_DISPLAYED_SKIN_PARTS
@ WITHER_INVULNERABLE_TIMER
@ ARMOR_STAND_LEFT_ARM_ROTATION
@ LIVING_POTION_EFFECT_AMBIENT
@ IRON_GOLEM_PLAYER_CREATED
@ ARMOR_STAND_HEAD_ROTATION
@ BOAT_LEFT_PADDLE_TURNING
@ MINECART_SHAKING_DIRECTION
@ AREA_EFFECT_CLOUD_COLOR
@ AREA_EFFECT_CLOUD_PARTICLE_ID
@ PLAYER_ADDITIONAL_HEARTHS
@ ENDER_CRYSTAL_BEAM_TARGET
@ ARMOR_STAND_RIGHT_ARM_ROTATION
@ SHULKER_FACING_DIRECTION
@ AREA_EFFECT_CLOUD_PARTICLE_PARAMETER1
@ WITHER_FIRST_HEAD_TARGET
@ ENDER_DRAGON_DRAGON_PHASE
@ ENTITY_CUSTOM_NAME_VISIBLE
@ BOAT_RIGHT_PADDLE_TURNING
@ AREA_EFFECT_CLOUD_PARTICLE_PARAMETER2
@ AREA_EFFECT_CLOUD_SINGLE_POINT_EFFECT
@ WITHER_THIRD_HEAD_TARGET
@ SHULKER_ATTACHMENT_FALLING_BLOCK_POSITION
@ WITHER_SKULL_INVULNERABLE
@ MINECART_COMMAND_BLOCK_LAST_OUTPUT
@ MINECART_SHAKING_MULTIPLIER
An object that can store incoming bytes and lets its clients read the bytes sequentially The bytes ar...
void HandleResourcePack(UInt8 a_Status)
bool IsCritical(void) const
Returns true if the arrow is set as critical.
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
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 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 WriteBEFloat(float a_Value)
void WriteString(const AString &a_Value)
void WriteBEUInt8(UInt8 a_Value)
void WriteBEInt8(Int8 a_Value)
Version
The protocol version number, received from the client in the Handshake 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 Version GetProtocolVersion() const override
Returns the protocol version.
virtual UInt32 GetProtocolMobType(eMonsterType a_MobType) const override
Converts eMonsterType to protocol-specific mob types.
virtual void HandlePacketResourcePackStatus(cByteBuffer &a_ByteBuffer) override
virtual void SendSoundEffect(const AString &a_SoundName, Vector3d a_Origin, float a_Volume, float a_Pitch) override
virtual void WriteMobMetadata(cPacketizer &a_Pkt, const cMonster &a_Mob) const override
Writes the mob-specific metadata for the specified mob.
State m_State
State of the protocol.
virtual UInt32 GetProtocolMobType(eMonsterType a_MobType) const override
Converts eMonsterType to protocol-specific mob types.
virtual void WriteItem(cPacketizer &a_Pkt, const cItem &a_Item) const override
Writes the item data into a packet.
@ METADATA_TYPE_OPTIONAL_POSITION