16 #include "../WorldStorage/FastNBT.h"
18 #include "../Entities/Boat.h"
19 #include "../Entities/EnderCrystal.h"
20 #include "../Entities/ExpOrb.h"
21 #include "../Entities/Minecart.h"
22 #include "../Entities/FallingBlock.h"
23 #include "../Entities/Painting.h"
24 #include "../Entities/Pickup.h"
25 #include "../Entities/Player.h"
26 #include "../Entities/ItemFrame.h"
27 #include "../Entities/ArrowEntity.h"
28 #include "../Entities/FireworkEntity.h"
29 #include "../Entities/SplashPotionEntity.h"
31 #include "../Mobs/IncludeAllMonsters.h"
33 #include "../BlockEntities/BedEntity.h"
34 #include "../BlockEntities/MobSpawnerEntity.h"
37 #include "../Server.h"
38 #include "../ClientHandle.h"
39 #include "../CompositeChat.h"
40 #include "../JsonUtils.h"
41 #include "../Bindings/PluginManager.h"
54 #pragma clang diagnostic push
55 #pragma clang diagnostic ignored "-Wduplicate-enum"
105 _FIREBALL_NEXT = _ENTITY_NEXT,
115 _HANGING_NEXT = _ENTITY_NEXT,
152 _AMBIENT_NEXT = _INSENTIENT_NEXT,
158 _CREATURE_NEXT = _INSENTIENT_NEXT,
168 _ANIMAL_NEXT = _AGEABLE_NEXT,
173 _ABSTRACT_HORSE_NEXT,
215 _GOLEM_NEXT = _CREATURE_NEXT,
226 _MONSTER_NEXT = _CREATURE_NEXT,
282 _FLYING_NEXT = _INSENTIENT_NEXT,
312 #pragma clang diagnostic pop
513 case mtBat:
return 65;
517 case mtCow:
return 92;
535 case mtPig:
return 90;
548 case mtVex:
return 35;
586 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, CursorX);
587 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, CursorY);
588 HANDLE_READ(a_ByteBuffer, ReadBEFloat,
float, CursorZ);
603 auto & BedEntity =
static_cast<const cBedEntity &
>(a_BlockEntity);
604 a_Writer.
AddInt(
"color", BedEntity.GetColor());
613 a_Writer.
AddShort(
"Delay", MobSpawnerEntity.GetSpawnDelay());
662 auto & Player =
static_cast<const cPlayer &
>(a_Entity);
673 a_Pkt.
WriteBEFloat(
static_cast<float>(Player.GetHealth()));
713 const cItem & MinecartContent = RideableMinecart.GetContent();
714 if (!MinecartContent.
IsEmpty())
743 switch (Projectile.GetProjectileKind())
783 auto & Boat =
static_cast<const cBoat &
>(a_Entity);
803 a_Pkt.
WriteBool(Boat.IsRightPaddleUsed());
807 a_Pkt.
WriteBool(Boat.IsLeftPaddleUsed());
814 auto & Frame =
static_cast<const cItemFrame &
>(a_Entity);
826 const auto & EnderCrystal =
static_cast<const cEnderCrystal &
>(a_Entity);
827 if (EnderCrystal.DisplaysBeam())
836 a_Pkt.
WriteBool(EnderCrystal.ShowsBottom());
876 auto & Bat =
static_cast<const cBat &
>(a_Mob);
895 auto & Cow =
static_cast<const cCow &
>(a_Mob);
922 auto & Enderman =
static_cast<const cEnderman &
>(a_Mob);
926 Carried |=
static_cast<UInt32>(Enderman.GetCarriedBlock() << 4);
927 Carried |= Enderman.GetCarriedMeta();
938 auto & Ghast =
static_cast<const cGhast &
>(a_Mob);
950 auto & Horse =
static_cast<const cHorse &
>(a_Mob);
956 if (Horse.IsSaddled())
960 if (Horse.IsChested())
964 if (Horse.IsEating())
968 if (Horse.IsRearing())
972 if (Horse.IsMthOpen())
989 Appearance = Horse.GetHorseColor();
990 Appearance |= Horse.GetHorseStyle() << 8;
1005 auto & MagmaCube =
static_cast<const cMagmaCube &
>(a_Mob);
1015 auto & Ocelot =
static_cast<const cOcelot &
>(a_Mob);
1021 Int8 OcelotStatus = 0;
1022 if (Ocelot.IsSitting())
1024 OcelotStatus |= 0x1;
1026 if (Ocelot.IsTame())
1028 OcelotStatus |= 0x4;
1043 auto & Pig =
static_cast<const cPig &
>(a_Mob);
1072 auto & Sheep =
static_cast<const cSheep &
>(a_Mob);
1080 Int8 SheepMetadata = 0;
1081 SheepMetadata =
static_cast<Int8>(Sheep.GetFurColor());
1082 if (Sheep.IsSheared())
1084 SheepMetadata |= 0x10;
1092 auto & Skeleton =
static_cast<const cSkeleton &
>(a_Mob);
1095 a_Pkt.
WriteBEUInt8(Skeleton.IsChargingBow() ? 0x01 : 0x00);
1099 a_Pkt.
WriteBool(Skeleton.IsChargingBow());
1105 auto & Slime =
static_cast<const cSlime &
>(a_Mob);
1114 auto & Villager =
static_cast<const cVillager &
>(a_Mob);
1127 auto & Witch =
static_cast<const cWitch &
>(a_Mob);
1136 auto & Wither =
static_cast<const cWither &
>(a_Mob);
1147 auto & Wolf =
static_cast<const cWolf &
>(a_Mob);
1152 Int8 WolfStatus = 0;
1153 if (Wolf.IsSitting())
1186 auto & Zombie =
static_cast<const cZombie &
>(a_Mob);
1195 auto & ZombiePigman =
static_cast<const cZombiePigman &
>(a_Mob);
1204 auto & ZombieVillager =
reinterpret_cast<const cZombieVillager &
>(a_Mob);
1207 a_Pkt.
WriteBool(ZombieVillager.IsBaby());
1249 ASSERT(!
"cProtocol_1_11::WriteMobMetadata: received unimplemented type");
1269 default:
UNREACHABLE(
"cProtocol_1_11::WriteMobMetadata: received mob of invalid type");
@ E_BLOCK_STANDING_BANNER
@ E_BLOCK_ENCHANTMENT_TABLE
@ PawnOffHandEquipmentBreaks
@ PawnFeetEquipmentBreaks
@ PawnMainHandEquipmentBreaks
@ PawnLegsEquipmentBreaks
@ PawnHeadEquipmentBreaks
@ PawnChestEquipmentBreaks
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.
@ MINECART_COMMAND_BLOCK_LAST_OUTPUT
@ LIVING_POTION_EFFECT_AMBIENT
@ LIVING_NUMBER_OF_ARROWS
@ AREA_EFFECT_CLOUD_SINGLE_POINT_EFFECT
@ ARMOR_STAND_RIGHT_LEG_ROTATION
@ PLAYER_DISPLAYED_SKIN_PARTS
@ ABSTRACT_SKELETON_ARMS_SWINGING
@ WITHER_INVULNERABLE_TIMER
@ BOAT_RIGHT_PADDLE_TURNING
@ PLAYER_ADDITIONAL_HEARTHS
@ AREA_EFFECT_CLOUD_PARTICLE_PARAMETER1
@ AREA_EFFECT_CLOUD_COLOR
@ MINECART_SHAKING_DIRECTION
@ ENDER_CRYSTAL_BEAM_TARGET
@ MINECART_SHAKING_MULTIPLIER
@ ARMOR_STAND_BODY_ROTATION
@ ARMOR_STAND_HEAD_ROTATION
@ ENDER_DRAGON_DRAGON_PHASE
@ ENTITY_CUSTOM_NAME_VISIBLE
@ ARMOR_STAND_LEFT_LEG_ROTATION
@ PIG_TOTAL_CARROT_ON_A_STICK_BOOST
@ ARMOR_STAND_LEFT_ARM_ROTATION
@ AREA_EFFECT_CLOUD_PARTICLE_PARAMETER2
@ IRON_GOLEM_PLAYER_CREATED
@ WITHER_FIRST_HEAD_TARGET
@ BOAT_LEFT_PADDLE_TURNING
@ ZOMBIE_VILLAGER_PROFESSION
@ ZOMBIE_VILLAGER_CONVERTING
@ ENDER_CRYSTAL_SHOW_BOTTOM
@ MINECART_FURNACE_POWERED
@ MINECART_COMMAND_BLOCK_COMMAND
@ SHULKER_FACING_DIRECTION
@ AREA_EFFECT_CLOUD_PARTICLE_ID
@ LIVING_POTION_EFFECT_COLOR
@ ARMOR_STAND_RIGHT_ARM_ROTATION
@ FIREWORK_BOOSTED_ENTITY_ID
@ WITHER_THIRD_HEAD_TARGET
@ SHULKER_ATTACHMENT_FALLING_BLOCK_POSITION
@ WITHER_SECOND_HEAD_TARGET
@ WITHER_SKULL_INVULNERABLE
@ AREA_EFFECT_CLOUD_RADIUS
BLOCKTYPE GetBlockType() const
An object that can store incoming bytes and lets its clients read the bytes sequentially The bytes ar...
bool ReadXYZPosition64(int &a_BlockX, int &a_BlockY, int &a_BlockZ)
void HandleRightClick(Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_Cursor, bool a_UsedMainHand)
bool IsCritical(void) const
Returns true if the arrow is set as critical.
virtual bool IsRclking(void) const
double GetSpeedZ(void) const
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.
UInt32 GetUniqueID(void) const
eEntityType GetEntityType(void) const
double GetPitch(void) const
virtual bool IsOnFire(void) const
double GetHeadYaw(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
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
static AString MobTypeToVanillaNBT(eMonsterType a_MobType)
Translates the MobType enum to the vanilla nbt name.
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 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)
Version
The protocol version number, received from the client in the Handshake packet.
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.
virtual Version GetProtocolVersion() const override
Returns the protocol version.
virtual void SendResetTitle(void) override
virtual void WriteBlockEntity(cFastNBTWriter &a_Writer, const cBlockEntity &a_BlockEntity) const override
Writes the block entity data for the specified block entity into the packet.
virtual void SendEntityAnimation(const cEntity &a_Entity, EntityAnimation a_Animation) override
virtual void SendCollectEntity(const cEntity &a_Collected, const cEntity &a_Collector, unsigned a_Count) 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 SendSpawnMob(const cMonster &a_Mob) override
virtual void SendHideTitle(void) 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 SendUpdateBlockEntity(cBlockEntity &a_BlockEntity) override
virtual void SendTitleTimes(int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks) override
virtual Version GetProtocolVersion() const override
Returns the protocol version.
State m_State
State of the protocol.
static eBlockFace FaceIntToBlockFace(Int32 a_FaceInt)
Converts the BlockFace received by the protocol into eBlockFace constants.
virtual void SendEntityAnimation(const cEntity &a_Entity, EntityAnimation a_Animation) override
virtual void WriteItem(cPacketizer &a_Pkt, const cItem &a_Item) const override
Writes the item data into a packet.
virtual void WriteBlockEntity(cFastNBTWriter &a_Writer, const cBlockEntity &a_BlockEntity) const override
Writes the block entity data for the specified block entity into the packet.
virtual void SendEntityPosition(const cEntity &a_Entity) override
@ METADATA_TYPE_OPTIONAL_POSITION
virtual signed char GetProtocolEntityStatus(EntityAnimation a_Animation) const override
Converts an animation into an ID suitable for use with the Entity Status packet.
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 BeginCompound(const AString &a_Name)
ContiguousByteBufferView GetResult(void) const