Cuberite
A lightweight, fast and extensible game server for Minecraft
Protocol_1_9.h
Go to the documentation of this file.
1 
2 // Protocol_1_9.h
3 
4 /*
5 Declares the 1.9 protocol classes:
6  - cProtocol_1_9_0
7  - release 1.9 protocol (#107)
8  - cProtocol_1_9_1
9  - release 1.9.1 protocol (#108)
10  - cProtocol_1_9_2
11  - release 1.9.2 protocol (#109)
12  - cProtocol_1_9_4
13  - release 1.9.4 protocol (#110)
14 */
15 
16 
17 
18 
19 
20 #pragma once
21 
22 #include "Protocol.h"
23 #include "Protocol_1_8.h"
24 
25 
26 
27 
28 
30  public cProtocol_1_8_0
31 {
33 
34 public:
35 
36  cProtocol_1_9_0(cClientHandle * a_Client, const AString & a_ServerAddress, State a_State);
37 
38  virtual void SendAttachEntity (const cEntity & a_Entity, const cEntity & a_Vehicle) override;
39  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;
40  virtual void SendBossBarRemove (UInt32 a_UniqueID) override;
41  virtual void SendBossBarUpdateFlags (UInt32 a_UniqueID, bool a_DarkenSky, bool a_PlayEndMusic, bool a_CreateFog) override;
42  virtual void SendBossBarUpdateHealth (UInt32 a_UniqueID, float a_FractionFilled) override;
43  virtual void SendBossBarUpdateStyle (UInt32 a_UniqueID, BossBarColor a_Color, BossBarDivisionType a_DivisionType) override;
44  virtual void SendBossBarUpdateTitle (UInt32 a_UniqueID, const cCompositeChat & a_Title) override;
45  virtual void SendDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle) override;
46  virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
47  virtual void SendEntityMetadata (const cEntity & a_Entity) override;
48  virtual void SendEntityPosition (const cEntity & a_Entity) override;
49  virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override;
50  virtual void SendKeepAlive (UInt32 a_PingID) override;
51  virtual void SendLeashEntity (const cEntity & a_Entity, const cEntity & a_EntityLeashedTo) override;
52  virtual void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY) override;
53  virtual void SendPaintingSpawn (const cPainting & a_Painting) override;
54  virtual void SendPlayerMoveLook (Vector3d a_Pos, float a_Yaw, float a_Pitch, bool a_IsRelative) override;
55  virtual void SendPlayerMoveLook (void) override;
56  virtual void SendPlayerPermissionLevel() override;
57  virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
58  virtual void SendSoundEffect (const AString & a_SoundName, Vector3d a_Origin, float a_Volume, float a_Pitch) override;
59  virtual void SendSpawnMob (const cMonster & a_Mob) override;
60  virtual void SendThunderbolt (Vector3i a_Origin) override;
61  virtual void SendUnleashEntity (const cEntity & a_Entity) override;
62  virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override;
63 
64 protected:
65 
68 
71 
72  virtual UInt32 GetPacketID(ePacketType a_Packet) const override;
73  virtual unsigned char GetProtocolEntityAnimation(EntityAnimation a_Animation) const override;
74  virtual signed char GetProtocolEntityStatus(EntityAnimation a_Animation) const override;
75  virtual UInt32 GetProtocolMobType(eMonsterType a_MobType) const override;
76  virtual Version GetProtocolVersion() const override;
77 
78  virtual bool HandlePacket (cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) override;
79  virtual void HandlePacketAnimation (cByteBuffer & a_ByteBuffer) override;
80  virtual void HandlePacketBlockDig (cByteBuffer & a_ByteBuffer) override;
81  virtual void HandlePacketBlockPlace (cByteBuffer & a_ByteBuffer) override;
82  virtual void HandlePacketBoatSteer (cByteBuffer & a_ByteBuffer);
83  virtual void HandlePacketClientSettings (cByteBuffer & a_ByteBuffer) override;
84  virtual void HandleConfirmTeleport (cByteBuffer & a_ByteBuffer);
85  virtual void HandlePacketEntityAction (cByteBuffer & a_ByteBuffer) override;
86  virtual void HandlePacketPlayerPos (cByteBuffer & a_ByteBuffer) override;
87  virtual void HandlePacketPlayerPosLook (cByteBuffer & a_ByteBuffer) override;
88  virtual void HandlePacketSteerVehicle (cByteBuffer & a_ByteBuffer) override;
89  virtual void HandlePacketTabComplete (cByteBuffer & a_ByteBuffer) override;
90  virtual void HandlePacketUpdateSign (cByteBuffer & a_ByteBuffer) override;
91  virtual void HandlePacketUseEntity (cByteBuffer & a_ByteBuffer) override;
92  virtual void HandlePacketUseItem (cByteBuffer & a_ByteBuffer);
93  virtual void HandlePacketVehicleMove (cByteBuffer & a_ByteBuffer);
94  virtual void HandlePacketWindowClick (cByteBuffer & a_ByteBuffer) override;
95  virtual void HandleVanillaPluginMessage (cByteBuffer & a_ByteBuffer, std::string_view a_Channel) override;
96 
97  virtual void ParseItemMetadata(cItem & a_Item, ContiguousByteBufferView a_Metadata) const override;
98  virtual void SendEntitySpawn(const cEntity & a_Entity, const UInt8 a_ObjectType, const Int32 a_ObjectData) override;
99  virtual void WriteBlockEntity(cFastNBTWriter & a_Writer, const cBlockEntity & a_BlockEntity) const override;
100  virtual void WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_Entity) const override;
101  virtual void WriteItem(cPacketizer & a_Pkt, const cItem & a_Item) const override;
102  virtual void WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) const override;
103 
106  {
120  } ;
121 } ;
122 
123 
124 
125 
126 
129  public cProtocol_1_9_0
130 {
132 
133 public:
134 
135  using Super::Super;
136 
137 protected:
138 
139  virtual void SendLogin(const cPlayer & a_Player, const cWorld & a_World) override;
140 
141  virtual Version GetProtocolVersion() const override;
142 } ;
143 
144 
145 
146 
147 
150  public cProtocol_1_9_1
151 {
153 
154 public:
155 
156  using Super::Super;
157 
158 protected:
159 
160  virtual Version GetProtocolVersion() const override;
161 } ;
162 
163 
164 
165 
166 
169  public cProtocol_1_9_2
170 {
172 
173 public:
174 
175  using Super::Super;
176 
177 protected:
178 
179  virtual void SendUpdateSign(Vector3i a_BlockPos, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override;
180 
181  virtual UInt32 GetPacketID(ePacketType a_Packet) const override;
182  virtual Version GetProtocolVersion() const override;
183 } ;
BossBarDivisionType
Definition: Defines.h:443
EntityAnimation
Definition: Defines.h:458
BossBarColor
Definition: Defines.h:428
unsigned int UInt32
Definition: Globals.h:157
std::basic_string_view< std::byte > ContiguousByteBufferView
Definition: Globals.h:376
signed int Int32
Definition: Globals.h:152
unsigned char UInt8
Definition: Globals.h:159
eMonsterType
Identifies individual monster type.
Definition: MonsterTypes.h:11
std::string AString
Definition: StringUtils.h:11
An object that can store incoming bytes and lets its clients read the bytes sequentially The bytes ar...
Definition: ByteBuffer.h:32
Container for a single chat message composed of multiple functional parts.
Definition: CompositeChat.h:34
Definition: Entity.h:76
Definition: ExpOrb.h:13
Definition: Player.h:29
Definition: Item.h:37
Encapsulates an in-game world map.
Definition: Map.h:83
Composes an individual packet in the protocol's m_OutPacketBuffer; sends it just before being destruc...
Definition: Packetizer.h:60
ePacketType
Logical types of outgoing packets.
Definition: Protocol.h:57
Version
The protocol version number, received from the client in the Handshake packet.
Definition: Protocol.h:335
cProtocol_1_8_0(cClientHandle *a_Client, const AString &a_ServerAddress, State a_State)
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.
Definition: Protocol_1_9.h:70
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)
eMetadataType
Types used within metadata.
Definition: Protocol_1_9.h:106
@ METADATA_TYPE_OPTIONAL_POSITION
Definition: Protocol_1_9.h:116
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
cProtocol_1_8_0 Super
Definition: Protocol_1_9.h:32
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.
Definition: Protocol_1_9.h:67
virtual signed char GetProtocolEntityStatus(EntityAnimation a_Animation) const override
Converts an animation into an ID suitable for use with the Entity Status packet.
The version 108 protocol, used by 1.9.1.
Definition: Protocol_1_9.h:130
cProtocol_1_9_0 Super
Definition: Protocol_1_9.h:131
virtual Version GetProtocolVersion() const override
Returns the protocol version.
virtual void SendLogin(const cPlayer &a_Player, const cWorld &a_World) override
The version 109 protocol, used by 1.9.2.
Definition: Protocol_1_9.h:151
cProtocol_1_9_1 Super
Definition: Protocol_1_9.h:152
virtual Version GetProtocolVersion() const override
Returns the protocol version.
The version 110 protocol, used by 1.9.3 and 1.9.4.
Definition: Protocol_1_9.h:170
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
Definition: World.h:53