Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
cClientHandle Class Reference

#include <ClientHandle.h>

Inheritance diagram for cClientHandle:
Inheritance graph
[legend]
Collaboration diagram for cClientHandle:
Collaboration graph
[legend]

Public Member Functions

void AddWantedChunk (int a_ChunkX, int a_ChunkZ)
 Adds the chunk specified to the list of chunks wanted for sending (m_ChunksToSend) More...
 
void Authenticate (const AString &a_Name, const cUUID &a_UUID, const Json::Value &a_Properties)
 Authenticates the specified user, called by cAuthenticator. More...
 
 cClientHandle (const AString &a_IPString, int a_ViewDistance)
 Creates a new client with the specified IP address in its description and the specified initial view distance. More...
 
bool CheckMultiLogin (const AString &a_Username)
 Kicks the client if the same username is already logged in. More...
 
void Destroy (void)
 
void ForgeAugmentServerListPing (Json::Value &a_Response)
 Add the Forge mod list to the server ping response. More...
 
void GenerateOfflineUUID (void)
 Generates an UUID based on the username stored for this client, and stores it in the m_UUID member. More...
 
const AStringGetClientBrand (void) const
 Returns the client brand received in the MC|Brand plugin message or set by a plugin. More...
 
const AStringMapGetForgeMods (void) const
 Returns the Forge mods installed on the client. More...
 
const AStringGetIPString (void) const
 
AString GetLocale (void) const
 
short GetPing (void) const
 
cPlayerGetPlayer (void)
 
const Json::Value & GetProperties (void) const
 
UInt32 GetProtocolVersion (void) const
 Returns the protocol version number of the protocol that the client is talking. More...
 
int GetRequestedViewDistance (void) const
 Returns the view distance that the player request, not the used view distance. More...
 
int GetUniqueID (void) const
 
const AStringGetUsername (void) const
 
const cUUIDGetUUID (void) const
 Returns the player's UUID, as used by the protocol. More...
 
int GetViewDistance (void) const
 Returns the view distance that the player currently have. More...
 
void HandleAnimation (int a_Animation)
 
void HandleAnvilItemName (const AString &a_ItemName)
 Called when the protocol receives a MC|ItemName plugin message, indicating that the player named an item in the anvil UI. More...
 
void HandleBeaconSelection (int a_PrimaryEffect, int a_SecondaryEffect)
 Called when the protocol receives a MC|Beacon plugin message, indicating that the player set an effect in the beacon UI. More...
 
void HandleChat (const AString &a_Message)
 Called when the protocol detects a chat packet. More...
 
void HandleCommandBlockBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, const AString &a_NewCommand)
 Called when the protocol receives a MC|AdvCdm plugin message, indicating that the player set a new command in the command block UI, for a block-based commandblock. More...
 
void HandleCommandBlockEntityChange (UInt32 a_EntityID, const AString &a_NewCommand)
 Called when the protocol receives a MC|AdvCdm plugin message, indicating that the player set a new command in the command block UI, for an entity-based commandblock (minecart?). More...
 
void HandleCreativeInventory (Int16 a_SlotNum, const cItem &a_HeldItem, eClickAction a_ClickAction)
 Called when the client clicks the creative inventory window. More...
 
void HandleEnchantItem (UInt8 a_WindowID, UInt8 a_Enchantment)
 Called when the player enchants an Item in the Enchanting table UI. More...
 
void HandleEntityCrouch (UInt32 a_EntityID, bool a_IsCrouching)
 
void HandleEntityLeaveBed (UInt32 a_EntityID)
 
void HandleEntitySprinting (UInt32 a_EntityID, bool a_IsSprinting)
 
bool HandleHandshake (const AString &a_Username)
 Called when the protocol handshake has been received (for protocol versions that support it; otherwise the first instant when a username is received). More...
 
void HandleKeepAlive (UInt32 a_KeepAliveID)
 
void HandleLeftClick (int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, UInt8 a_Status)
 
bool HandleLogin (const AString &a_Username)
 Called when the protocol has finished logging the user in. More...
 
void HandleNPCTrade (int a_SlotNum)
 Called when the protocol receives a MC|TrSel packet, indicating that the player used a trade in the NPC UI. More...
 
void HandleOpenHorseInventory (UInt32 a_EntityID)
 Handles a player opening their inventory while riding a horse. More...
 
void HandlePing (void)
 
void HandlePlayerAbilities (bool a_CanFly, bool a_IsFlying, float FlyingSpeed, float WalkingSpeed)
 
void HandlePlayerLook (float a_Rotation, float a_Pitch, bool a_IsOnGround)
 
void HandlePlayerMoveLook (double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Rotation, float a_Pitch, bool a_IsOnGround)
 
void HandlePlayerPos (double a_PosX, double a_PosY, double a_PosZ, double a_Stance, bool a_IsOnGround)
 Verifies and sets player position, performing relevant checks Calls relevant methods to process movement related statistics Requires state of previous position and on-ground status, so must be called when these are still intact. More...
 
void HandlePluginMessage (const AString &a_Channel, const AString &a_Message)
 
void HandleRespawn (void)
 
void HandleRightClick (int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, eHand a_Hand)
 
void HandleSlotSelected (Int16 a_SlotNum)
 
void HandleSpectate (const cUUID &a_PlayerUUID)
 
void HandleSteerVehicle (float Forward, float Sideways)
 
void HandleTabCompletion (const AString &a_Text)
 
void HandleUnmount (void)
 
void HandleUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString &a_Line1, const AString &a_Line2, const AString &a_Line3, const AString &a_Line4)
 
void HandleUseEntity (UInt32 a_TargetEntityID, bool a_IsLeftClick)
 
void HandleUseItem (eHand a_Hand)
 
void HandleWindowClick (UInt8 a_WindowID, Int16 a_SlotNum, eClickAction a_ClickAction, const cItem &a_HeldItem)
 
void HandleWindowClose (UInt8 a_WindowID)
 
bool HasPluginChannel (const AString &a_PluginChannel)
 
void InvalidateCachedSentChunk ()
 
bool IsDestroyed (void) const
 
bool IsDestroying (void) const
 
bool IsForgeClient (void) const
 Returns true if the client is modded with Forge. More...
 
bool IsLoggedIn (void) const
 
bool IsPlayerChunkSent ()
 
bool IsPlaying (void) const
 
void Kick (const AString &a_Reason)
 
void PacketBufferFull (void)
 
void PacketError (UInt32 a_PacketType)
 
void PacketUnknown (UInt32 a_PacketType)
 
void RemoveFromAllChunks (void)
 Removes the client from all chunks. More...
 
void RemoveFromWorld (void)
 Called when the player moves into a different world. More...
 
void SendAttachEntity (const cEntity &a_Entity, const cEntity &a_Vehicle)
 
void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
 
void SendBlockBreakAnim (UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage)
 
void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
 
void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector &a_Changes)
 
void SendCameraSetTo (const cEntity &a_Entity)
 
void SendChat (const AString &a_Message, eMessageType a_ChatPrefix, const AString &a_AdditionalData="")
 
void SendChat (const cCompositeChat &a_Message)
 
void SendChatAboveActionBar (const AString &a_Message, eMessageType a_ChatPrefix, const AString &a_AdditionalData="")
 
void SendChatAboveActionBar (const cCompositeChat &a_Message)
 
void SendChatRaw (const AString &a_MessageRaw, eChatType a_Type)
 
void SendChatSystem (const AString &a_Message, eMessageType a_ChatPrefix, const AString &a_AdditionalData="")
 
void SendChatSystem (const cCompositeChat &a_Message)
 
void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer &a_Serializer)
 
void SendCollectEntity (const cEntity &a_Entity, const cPlayer &a_Player, int a_Count)
 
void SendData (const char *a_Data, size_t a_Size)
 
void SendDestroyEntity (const cEntity &a_Entity)
 
void SendDetachEntity (const cEntity &a_Entity, const cEntity &a_PreviousVehicle)
 
void SendDisconnect (const AString &a_Reason)
 
void SendDisplayObjective (const AString &a_Objective, cScoreboard::eDisplaySlot a_Display)
 
void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ)
 
void SendEntityAnimation (const cEntity &a_Entity, char a_Animation)
 
void SendEntityEffect (const cEntity &a_Entity, int a_EffectID, int a_Amplifier, int a_Duration)
 
void SendEntityEquipment (const cEntity &a_Entity, short a_SlotNum, const cItem &a_Item)
 
void SendEntityHeadLook (const cEntity &a_Entity)
 
void SendEntityLook (const cEntity &a_Entity)
 
void SendEntityMetadata (const cEntity &a_Entity)
 
void SendEntityProperties (const cEntity &a_Entity)
 
void SendEntityRelMove (const cEntity &a_Entity, char a_RelX, char a_RelY, char a_RelZ)
 
void SendEntityRelMoveLook (const cEntity &a_Entity, char a_RelX, char a_RelY, char a_RelZ)
 
void SendEntityStatus (const cEntity &a_Entity, char a_Status)
 
void SendEntityVelocity (const cEntity &a_Entity)
 
void SendExperience (void)
 
void SendExperienceOrb (const cExpOrb &a_ExpOrb)
 
void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray &a_BlocksAffected, const Vector3d &a_PlayerMotion)
 
void SendGameMode (eGameMode a_GameMode)
 
void SendHealth (void)
 
void SendHeldItemChange (int a_ItemIndex)
 
void SendHideTitle (void)
 
void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem &a_Item)
 
void SendLeashEntity (const cEntity &a_Entity, const cEntity &a_EntityLeashedTo)
 
void SendMapData (const cMap &a_Map, int a_DataStartX, int a_DataStartY)
 
void SendPaintingSpawn (const cPainting &a_Painting)
 
void SendParticleEffect (const AString &a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount)
 
void SendParticleEffect (const AString &a_ParticleName, const Vector3f a_Src, const Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array< int, 2 > a_Data)
 
void SendPickupSpawn (const cPickup &a_Pickup)
 
void SendPlayerAbilities (void)
 
void SendPlayerListAddPlayer (const cPlayer &a_Player)
 
void SendPlayerListRemovePlayer (const cPlayer &a_Player)
 
void SendPlayerListUpdateDisplayName (const cPlayer &a_Player, const AString &a_CustomName)
 
void SendPlayerListUpdateGameMode (const cPlayer &a_Player)
 
void SendPlayerListUpdatePing (const cPlayer &a_Player)
 
void SendPlayerMaxSpeed (void)
 Informs the client of the maximum player speed (1.6.1+) More...
 
void SendPlayerMoveLook (void)
 
void SendPlayerPosition (void)
 
void SendPlayerSpawn (const cPlayer &a_Player)
 
void SendPluginMessage (const AString &a_Channel, const AString &a_Message)
 
void SendRemoveEntityEffect (const cEntity &a_Entity, int a_EffectID)
 
void SendResetTitle (void)
 
void SendRespawn (eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks=false)
 
void SendScoreboardObjective (const AString &a_Name, const AString &a_DisplayName, Byte a_Mode)
 
void SendScoreUpdate (const AString &a_Objective, const AString &a_Player, cObjective::Score a_Score, Byte a_Mode)
 
void SendSetRawSubTitle (const AString &a_SubTitle)
 
void SendSetRawTitle (const AString &a_Title)
 
void SendSetSubTitle (const cCompositeChat &a_SubTitle)
 
void SendSetTitle (const cCompositeChat &a_Title)
 
void SendSoundEffect (const AString &a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
 
void SendSoundEffect (const AString &a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch)
 
void SendSoundParticleEffect (const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
 
void SendSpawnFallingBlock (const cFallingBlock &a_FallingBlock)
 
void SendSpawnMob (const cMonster &a_Mob)
 
void SendSpawnObject (const cEntity &a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch)
 
void SendSpawnVehicle (const cEntity &a_Vehicle, char a_VehicleType, char a_VehicleSubType=0)
 
void SendStatistics (const cStatManager &a_Manager)
 
void SendTabCompletionResults (const AStringVector &a_Results)
 
void SendTeleportEntity (const cEntity &a_Entity)
 
void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ)
 
void SendTimeUpdate (Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_DoDaylightCycle)
 
void SendTitleTimes (int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks)
 
void SendUnleashEntity (const cEntity &a_Entity)
 
void SendUnloadChunk (int a_ChunkX, int a_ChunkZ)
 
void SendUpdateBlockEntity (cBlockEntity &a_BlockEntity)
 
void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString &a_Line1, const AString &a_Line2, const AString &a_Line3, const AString &a_Line4)
 
void SendUseBed (const cEntity &a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ)
 
void SendWeather (eWeather a_Weather)
 
void SendWholeInventory (const cWindow &a_Window)
 
void SendWindowClose (const cWindow &a_Window)
 
void SendWindowOpen (const cWindow &a_Window)
 
void SendWindowProperty (const cWindow &a_Window, short a_Property, short a_Value)
 
void ServerTick (float a_Dt)
 Called while the client is being ticked from the cServer object. More...
 
void SetClientBrand (const AString &a_ClientBrand)
 Called by the protocol when it receives the MC|Brand plugin message. More...
 
void SetIPString (const AString &a_IPString)
 Sets the IP string that the client is using. More...
 
void SetIsForgeClient ()
 Mark a client connection as using Forge. More...
 
void SetLocale (const AString &a_Locale)
 
void SetProperties (const Json::Value &a_Properties)
 Sets the player's properties, such as skin image and signature. More...
 
void SetProtocolVersion (UInt32 a_ProtocolVersion)
 Called by the protocol recognizer when the protocol version is known. More...
 
void SetUsername (const AString &a_Username)
 
void SetUUID (const cUUID &a_UUID)
 Sets the player's UUID, as used by the protocol. More...
 
void SetViewDistance (int a_ViewDistance)
 Sets the maximal view distance. More...
 
bool StreamNextChunk ()
 This function sends a new unloaded chunk to the player. More...
 
void Tick (float a_Dt)
 Called while the client is being ticked from the world via its cPlayer object. More...
 
void UnloadOutOfRangeChunks (void)
 Remove all loaded chunks that are no longer in range. More...
 
bool WantsSendChunk (int a_ChunkX, int a_ChunkZ)
 Returns true if the client wants the chunk specified to be sent (in m_ChunksToSend) More...
 
virtual ~cClientHandle () override
 
- Public Member Functions inherited from cTCPLink::cCallbacks
virtual void OnTlsHandshakeCompleted (void)
 Called when the TLS handshake has been completed and communication can continue regularly. More...
 
virtual ~cCallbacks ()
 

Static Public Member Functions

static AString FormatChatPrefix (bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2)
 
static AString FormatMessageType (bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString &a_AdditionalData)
 Formats the type of message with the proper color and prefix for sending to the client. More...
 
static cUUID GenerateOfflineUUID (const AString &a_Username)
 Generates an UUID based on the player name provided. More...
 
static bool IsUUIDOnline (const cUUID &a_UUID)
 Returns true if the UUID is generated by online auth, false if it is an offline-generated UUID. More...
 

Static Public Attributes

static const int DEFAULT_VIEW_DISTANCE = 10
 
static float FASTBREAK_PERCENTAGE
 The percentage how much a block has to be broken. More...
 
static const int MAX_VIEW_DISTANCE = 32
 
static const int MIN_VIEW_DISTANCE = 1
 

Private Types

typedef std::set< AStringcChannels
 The type used for storing the names of registered plugin channels. More...
 
enum  eState {
  csConnected, csAuthenticating, csAuthenticated, csDownloadingWorld,
  csConfirmingPos, csPlaying, csKicked, csQueuedForDestruction,
  csDestroying, csDestroyed
}
 

Private Member Functions

AStringVector BreakApartPluginChannels (const AString &a_PluginChannels)
 Converts the protocol-formatted channel list (NUL-separated) into a proper string vector. More...
 
bool CheckBlockInteractionsRate (void)
 Returns true if the rate block interactions is within a reasonable limit (bot protection) More...
 
void FinishAuthenticate (const AString &a_Name, const cUUID &a_UUID, const Json::Value &a_Properties)
 Finish logging the user in after authenticating. More...
 
void FinishDigAnimation ()
 The clients will receive a finished dig animation. More...
 
void HandleBlockDigFinished (int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta)
 Handles the DIG_FINISHED dig packet: More...
 
void HandleBlockDigStarted (int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta)
 Handles the DIG_STARTED dig packet: More...
 
virtual void OnError (int a_ErrorCode, const AString &a_ErrorMsg) override
 Called when an error is detected on the connection. More...
 
virtual void OnLinkCreated (cTCPLinkPtr a_Link) override
 Called when the cTCPLink for the connection is created. More...
 
virtual void OnReceivedData (const char *a_Data, size_t a_Length) override
 Called when there's data incoming from the remote peer. More...
 
virtual void OnRemoteClosed (void) override
 Called when the remote end closes the connection. More...
 
void ProcessProtocolInOut (void)
 Processes the data in the network input and output buffers. More...
 
void RegisterPluginChannels (const AStringVector &a_ChannelList)
 Adds all of the channels to the list of current plugin channels. More...
 
void SetSelf (cClientHandlePtr a_Self)
 Called right after the instance is created to store its SharedPtr inside. More...
 
void SocketClosed (void)
 Called when the network socket has been closed. More...
 
void StreamChunk (int a_ChunkX, int a_ChunkZ, cChunkSender::eChunkPriority a_Priority)
 Adds a single chunk to be streamed to the client; used by StreamChunks() More...
 
void UnregisterPluginChannels (const AStringVector &a_ChannelList)
 Removes all of the channels from the list of current plugin channels. More...
 

Private Attributes

int m_BlockDigAnimSpeed
 
int m_BlockDigAnimStage
 
int m_BlockDigAnimX
 
int m_BlockDigAnimY
 
int m_BlockDigAnimZ
 
float m_BreakProgress
 
cChunkCoords m_CachedSentChunk
 This is an optimization which saves you an iteration of m_SentChunks if you just want to know whether or not the player is standing at a sent chunk. More...
 
std::unordered_set< cChunkCoords, cChunkCoordsHashm_ChunksToSend
 
AString m_ClientBrand
 The brand identification of the client, as received in the MC|Brand plugin message or set from a plugin. More...
 
Vector3d m_ConfirmPosition
 
cCriticalSection m_CSChunkLists
 
cCriticalSection m_CSIncomingData
 Protects m_IncomingData against multithreaded access. More...
 
cCriticalSection m_CSOutgoingData
 Protects m_OutgoingData against multithreaded access. More...
 
cCriticalSection m_CSState
 
int m_CurrentViewDistance
 The actual view distance used, the minimum of client's requested view distance and world's max view distance. More...
 
cForgeHandshake m_ForgeHandshake
 Forge handshake state machine. More...
 
AStringMap m_ForgeMods
 Forge mods and versions installed on this client. More...
 
bool m_HasSentDC
 True if a Disconnect packet has been sent in either direction. More...
 
bool m_HasSentPlayerChunk
 Set to true when the chunk where the player is is sent to the client. More...
 
bool m_HasStartedDigging
 
AString m_IncomingData
 Queue for the incoming data received on the link until it is processed in Tick(). More...
 
AString m_IPString
 
int m_LastDigBlockX
 
int m_LastDigBlockY
 
int m_LastDigBlockZ
 
Vector3i m_LastPlacedSign
 The positions from the last sign that the player placed. More...
 
eDimension m_LastSentDimension
 The dimension that was last sent to a player in a Respawn or Login packet. More...
 
int m_LastStreamedChunkX
 
int m_LastStreamedChunkZ
 
cTCPLinkPtr m_Link
 The link that is used for network communication. More...
 
std::unordered_set< cChunkCoords, cChunkCoordsHashm_LoadedChunks
 
AString m_Locale
 Client Settings. More...
 
int m_NumBlockChangeInteractionsThisTick
 Number of place or break interactions this tick. More...
 
int m_NumExplosionsThisTick
 Number of explosions sent this tick. More...
 
AString m_OutgoingData
 Buffer for storing outgoing data from any thread; will get sent in Tick() (to prevent deadlocks). More...
 
AString m_Password
 
std::chrono::steady_clock::duration m_Ping
 Duration of the last completed client ping. More...
 
UInt32 m_PingID
 ID of the last ping request sent to the client. More...
 
std::chrono::steady_clock::time_point m_PingStartTime
 Time of the last ping request sent to the client. More...
 
cPlayerm_Player
 
std::unique_ptr< cPlayerm_PlayerPtr
 
cChannels m_PluginChannels
 The plugin channels that the client has registered. More...
 
Json::Value m_Properties
 
std::unique_ptr< cProtocolm_Protocol
 
UInt32 m_ProtocolVersion
 The version of the protocol that the client is talking, or 0 if unknown. More...
 
int m_RequestedViewDistance
 The requested view distance from the player. More...
 
cClientHandlePtr m_Self
 Shared pointer to self, so that this instance can keep itself alive when needed. More...
 
cChunkCoordsList m_SentChunks
 
bool m_ShouldCheckDownloaded
 If set to true during csDownloadingWorld, the tick thread calls CheckIfWorldDownloaded() More...
 
std::atomic< eStatem_State
 The current (networking) state of the client. More...
 
std::atomic< int > m_TicksSinceLastPacket
 Number of ticks since the last network packet was received (increased in Tick(), reset in OnReceivedData()) More...
 
int m_UniqueID
 ID used for identification during authenticating. More...
 
AString m_Username
 
cUUID m_UUID
 Contains the UUID used by Mojang to identify the player's account. More...
 

Static Private Attributes

static int s_ClientCount = 0
 

Friends

class cForgeHandshake
 
class cServer
 

Detailed Description

Definition at line 46 of file ClientHandle.h.

Member Typedef Documentation

typedef std::set<AString> cClientHandle::cChannels
private

The type used for storing the names of registered plugin channels.

Definition at line 407 of file ClientHandle.h.

Member Enumeration Documentation

enum cClientHandle::eState
private
Enumerator
csConnected 

The client has just connected, waiting for their handshake / login.

csAuthenticating 

The client has logged in, waiting for external authentication.

csAuthenticated 

The client has been authenticated, will start streaming chunks in the next tick.

csDownloadingWorld 

The client is waiting for chunks, we're waiting for the loader to provide and send them.

csConfirmingPos 

The client has been sent the position packet, waiting for them to repeat the position back.

csPlaying 

Normal gameplay.

csKicked 

Disconnect packet sent, awaiting connection closure.

csQueuedForDestruction 

The client will be destroyed in the next tick (flag set when socket closed)

csDestroying 

The client is being destroyed, don't queue any more packets / don't add to chunks.

csDestroyed 

The client has been destroyed, the destructor is to be called from the owner thread.

Definition at line 493 of file ClientHandle.h.

Constructor & Destructor Documentation

cClientHandle::cClientHandle ( const AString a_IPString,
int  a_ViewDistance 
)

Creates a new client with the specified IP address in its description and the specified initial view distance.

Definition at line 64 of file ClientHandle.cpp.

cClientHandle::~cClientHandle ( )
overridevirtual

Definition at line 110 of file ClientHandle.cpp.

Member Function Documentation

void cClientHandle::AddWantedChunk ( int  a_ChunkX,
int  a_ChunkZ 
)

Adds the chunk specified to the list of chunks wanted for sending (m_ChunksToSend)

Definition at line 3242 of file ClientHandle.cpp.

void cClientHandle::Authenticate ( const AString a_Name,
const cUUID a_UUID,
const Json::Value &  a_Properties 
)

Authenticates the specified user, called by cAuthenticator.

Definition at line 309 of file ClientHandle.cpp.

AStringVector cClientHandle::BreakApartPluginChannels ( const AString a_PluginChannels)
private

Converts the protocol-formatted channel list (NUL-separated) into a proper string vector.

Definition at line 906 of file ClientHandle.cpp.

bool cClientHandle::CheckBlockInteractionsRate ( void  )
private

Returns true if the rate block interactions is within a reasonable limit (bot protection)

Definition at line 2043 of file ClientHandle.cpp.

bool cClientHandle::CheckMultiLogin ( const AString a_Username)

Kicks the client if the same username is already logged in.

Returns false if the client has been kicked, true otherwise.

Definition at line 1845 of file ClientHandle.cpp.

void cClientHandle::Destroy ( void  )

Definition at line 147 of file ClientHandle.cpp.

void cClientHandle::FinishAuthenticate ( const AString a_Name,
const cUUID a_UUID,
const Json::Value &  a_Properties 
)
private

Finish logging the user in after authenticating.

Definition at line 359 of file ClientHandle.cpp.

void cClientHandle::FinishDigAnimation ( )
private

The clients will receive a finished dig animation.

Definition at line 1384 of file ClientHandle.cpp.

void cClientHandle::ForgeAugmentServerListPing ( Json::Value &  a_Response)
inline

Add the Forge mod list to the server ping response.

Definition at line 270 of file ClientHandle.h.

AString cClientHandle::FormatChatPrefix ( bool  ShouldAppendChatPrefixes,
AString  a_ChatPrefixS,
AString  m_Color1,
AString  m_Color2 
)
static

Definition at line 221 of file ClientHandle.cpp.

AString cClientHandle::FormatMessageType ( bool  ShouldAppendChatPrefixes,
eMessageType  a_ChatPrefix,
const AString a_AdditionalData 
)
static

Formats the type of message with the proper color and prefix for sending to the client.

Definition at line 237 of file ClientHandle.cpp.

void cClientHandle::GenerateOfflineUUID ( void  )

Generates an UUID based on the username stored for this client, and stores it in the m_UUID member.

This is used for the offline (non-auth) mode, when there's no UUID source. Each username generates a unique and constant UUID, so that when the player reconnects with the same name, their UUID is the same. Internally calls the GenerateOfflineUUID static function.

Definition at line 212 of file ClientHandle.cpp.

cUUID cClientHandle::GenerateOfflineUUID ( const AString a_Username)
static

Generates an UUID based on the player name provided.

This is used for the offline (non-auth) mode, when there's no UUID source. Each username generates a unique and constant UUID, so that when the player reconnects with the same name, their UUID is the same.

Definition at line 270 of file ClientHandle.cpp.

const AString& cClientHandle::GetClientBrand ( void  ) const
inline

Returns the client brand received in the MC|Brand plugin message or set by a plugin.

Definition at line 259 of file ClientHandle.h.

const AStringMap& cClientHandle::GetForgeMods ( void  ) const
inline

Returns the Forge mods installed on the client.

Definition at line 262 of file ClientHandle.h.

const AString& cClientHandle::GetIPString ( void  ) const
inline

Definition at line 69 of file ClientHandle.h.

AString cClientHandle::GetLocale ( void  ) const
inline

Definition at line 248 of file ClientHandle.h.

short cClientHandle::GetPing ( void  ) const
inline

Definition at line 236 of file ClientHandle.h.

cPlayer* cClientHandle::GetPlayer ( void  )
inline

Definition at line 75 of file ClientHandle.h.

const Json::Value& cClientHandle::GetProperties ( void  ) const
inline

Definition at line 85 of file ClientHandle.h.

UInt32 cClientHandle::GetProtocolVersion ( void  ) const
inline

Returns the protocol version number of the protocol that the client is talking.

Returns zero if the protocol version is not (yet) known.

Definition at line 391 of file ClientHandle.h.

int cClientHandle::GetRequestedViewDistance ( void  ) const
inline

Returns the view distance that the player request, not the used view distance.

Definition at line 245 of file ClientHandle.h.

int cClientHandle::GetUniqueID ( void  ) const
inline

Definition at line 250 of file ClientHandle.h.

const AString & cClientHandle::GetUsername ( void  ) const

Definition at line 3183 of file ClientHandle.cpp.

const cUUID& cClientHandle::GetUUID ( void  ) const
inline

Returns the player's UUID, as used by the protocol.

Definition at line 78 of file ClientHandle.h.

int cClientHandle::GetViewDistance ( void  ) const
inline

Returns the view distance that the player currently have.

Definition at line 242 of file ClientHandle.h.

void cClientHandle::HandleAnimation ( int  a_Animation)

Definition at line 1593 of file ClientHandle.cpp.

void cClientHandle::HandleAnvilItemName ( const AString a_ItemName)

Called when the protocol receives a MC|ItemName plugin message, indicating that the player named an item in the anvil UI.

Definition at line 1043 of file ClientHandle.cpp.

void cClientHandle::HandleBeaconSelection ( int  a_PrimaryEffect,
int  a_SecondaryEffect 
)

Called when the protocol receives a MC|Beacon plugin message, indicating that the player set an effect in the beacon UI.

Definition at line 960 of file ClientHandle.cpp.

void cClientHandle::HandleBlockDigFinished ( int  a_BlockX,
int  a_BlockY,
int  a_BlockZ,
eBlockFace  a_BlockFace,
BLOCKTYPE  a_OldBlock,
NIBBLETYPE  a_OldMeta 
)
private

Handles the DIG_FINISHED dig packet:

Definition at line 1292 of file ClientHandle.cpp.

void cClientHandle::HandleBlockDigStarted ( int  a_BlockX,
int  a_BlockY,
int  a_BlockZ,
eBlockFace  a_BlockFace,
BLOCKTYPE  a_OldBlock,
NIBBLETYPE  a_OldMeta 
)
private

Handles the DIG_STARTED dig packet:

Definition at line 1219 of file ClientHandle.cpp.

void cClientHandle::HandleChat ( const AString a_Message)

Called when the protocol detects a chat packet.

Definition at line 1530 of file ClientHandle.cpp.

void cClientHandle::HandleCommandBlockBlockChange ( int  a_BlockX,
int  a_BlockY,
int  a_BlockZ,
const AString a_NewCommand 
)

Called when the protocol receives a MC|AdvCdm plugin message, indicating that the player set a new command in the command block UI, for a block-based commandblock.

Definition at line 1009 of file ClientHandle.cpp.

void cClientHandle::HandleCommandBlockEntityChange ( UInt32  a_EntityID,
const AString a_NewCommand 
)

Called when the protocol receives a MC|AdvCdm plugin message, indicating that the player set a new command in the command block UI, for an entity-based commandblock (minecart?).

Definition at line 1033 of file ClientHandle.cpp.

void cClientHandle::HandleCreativeInventory ( Int16  a_SlotNum,
const cItem a_HeldItem,
eClickAction  a_ClickAction 
)

Called when the client clicks the creative inventory window.

a_ClickAction specifies whether the click was inside the window or not (caLeftClick or caLeftClickOutside).

Definition at line 751 of file ClientHandle.cpp.

void cClientHandle::HandleEnchantItem ( UInt8  a_WindowID,
UInt8  a_Enchantment 
)

Called when the player enchants an Item in the Enchanting table UI.

Definition at line 772 of file ClientHandle.cpp.

void cClientHandle::HandleEntityCrouch ( UInt32  a_EntityID,
bool  a_IsCrouching 
)

Definition at line 1894 of file ClientHandle.cpp.

void cClientHandle::HandleEntityLeaveBed ( UInt32  a_EntityID)

Definition at line 1909 of file ClientHandle.cpp.

void cClientHandle::HandleEntitySprinting ( UInt32  a_EntityID,
bool  a_IsSprinting 
)

Definition at line 1926 of file ClientHandle.cpp.

bool cClientHandle::HandleHandshake ( const AString a_Username)

Called when the protocol handshake has been received (for protocol versions that support it; otherwise the first instant when a username is received).

Returns true if the player is to be let in, false if they were disconnected

Definition at line 1873 of file ClientHandle.cpp.

void cClientHandle::HandleKeepAlive ( UInt32  a_KeepAliveID)

Definition at line 1833 of file ClientHandle.cpp.

void cClientHandle::HandleLeftClick ( int  a_BlockX,
int  a_BlockY,
int  a_BlockZ,
eBlockFace  a_BlockFace,
UInt8  a_Status 
)

Definition at line 1060 of file ClientHandle.cpp.

bool cClientHandle::HandleLogin ( const AString a_Username)

Called when the protocol has finished logging the user in.

Return true to allow the user in; false to kick them.

Definition at line 714 of file ClientHandle.cpp.

void cClientHandle::HandleNPCTrade ( int  a_SlotNum)

Called when the protocol receives a MC|TrSel packet, indicating that the player used a trade in the NPC UI.

Definition at line 669 of file ClientHandle.cpp.

void cClientHandle::HandleOpenHorseInventory ( UInt32  a_EntityID)

Handles a player opening their inventory while riding a horse.

Parameters
a_EntityIDID of the player that is to open the inventory. Should be the same as GetPlayer()->GetUniqueID().

Definition at line 679 of file ClientHandle.cpp.

void cClientHandle::HandlePing ( void  )

Definition at line 691 of file ClientHandle.cpp.

void cClientHandle::HandlePlayerAbilities ( bool  a_CanFly,
bool  a_IsFlying,
float  FlyingSpeed,
float  WalkingSpeed 
)

Definition at line 813 of file ClientHandle.cpp.

void cClientHandle::HandlePlayerLook ( float  a_Rotation,
float  a_Pitch,
bool  a_IsOnGround 
)

Definition at line 1566 of file ClientHandle.cpp.

void cClientHandle::HandlePlayerMoveLook ( double  a_PosX,
double  a_PosY,
double  a_PosZ,
double  a_Stance,
float  a_Rotation,
float  a_Pitch,
bool  a_IsOnGround 
)

Definition at line 1583 of file ClientHandle.cpp.

void cClientHandle::HandlePlayerPos ( double  a_PosX,
double  a_PosY,
double  a_PosZ,
double  a_Stance,
bool  a_IsOnGround 
)

Verifies and sets player position, performing relevant checks Calls relevant methods to process movement related statistics Requires state of previous position and on-ground status, so must be called when these are still intact.

Definition at line 826 of file ClientHandle.cpp.

void cClientHandle::HandlePluginMessage ( const AString a_Channel,
const AString a_Message 
)

Definition at line 871 of file ClientHandle.cpp.

void cClientHandle::HandleRespawn ( void  )

Definition at line 1818 of file ClientHandle.cpp.

void cClientHandle::HandleRightClick ( int  a_BlockX,
int  a_BlockY,
int  a_BlockZ,
eBlockFace  a_BlockFace,
int  a_CursorX,
int  a_CursorY,
int  a_CursorZ,
eHand  a_Hand 
)

Definition at line 1409 of file ClientHandle.cpp.

void cClientHandle::HandleSlotSelected ( Int16  a_SlotNum)

Definition at line 1608 of file ClientHandle.cpp.

void cClientHandle::HandleSpectate ( const cUUID a_PlayerUUID)

Definition at line 1618 of file ClientHandle.cpp.

void cClientHandle::HandleSteerVehicle ( float  Forward,
float  Sideways 
)

Definition at line 1631 of file ClientHandle.cpp.

void cClientHandle::HandleTabCompletion ( const AString a_Text)

Definition at line 1954 of file ClientHandle.cpp.

void cClientHandle::HandleUnmount ( void  )

Definition at line 1941 of file ClientHandle.cpp.

void cClientHandle::HandleUpdateSign ( int  a_BlockX,
int  a_BlockY,
int  a_BlockZ,
const AString a_Line1,
const AString a_Line2,
const AString a_Line3,
const AString a_Line4 
)

Definition at line 1670 of file ClientHandle.cpp.

void cClientHandle::HandleUseEntity ( UInt32  a_TargetEntityID,
bool  a_IsLeftClick 
)

Definition at line 1687 of file ClientHandle.cpp.

void cClientHandle::HandleUseItem ( eHand  a_Hand)

Definition at line 1758 of file ClientHandle.cpp.

void cClientHandle::HandleWindowClick ( UInt8  a_WindowID,
Int16  a_SlotNum,
eClickAction  a_ClickAction,
const cItem a_HeldItem 
)

Definition at line 1649 of file ClientHandle.cpp.

void cClientHandle::HandleWindowClose ( UInt8  a_WindowID)

Definition at line 1640 of file ClientHandle.cpp.

bool cClientHandle::HasPluginChannel ( const AString a_PluginChannel)

Definition at line 3218 of file ClientHandle.cpp.

void cClientHandle::InvalidateCachedSentChunk ( )

Definition at line 2022 of file ClientHandle.cpp.

bool cClientHandle::IsDestroyed ( void  ) const
inline

Definition at line 138 of file ClientHandle.h.

bool cClientHandle::IsDestroying ( void  ) const
inline

Definition at line 139 of file ClientHandle.h.

bool cClientHandle::IsForgeClient ( void  ) const
inline

Returns true if the client is modded with Forge.

Definition at line 265 of file ClientHandle.h.

bool cClientHandle::IsLoggedIn ( void  ) const
inline

Definition at line 127 of file ClientHandle.h.

bool cClientHandle::IsPlayerChunkSent ( )

Definition at line 2034 of file ClientHandle.cpp.

bool cClientHandle::IsPlaying ( void  ) const
inline

Definition at line 137 of file ClientHandle.h.

bool cClientHandle::IsUUIDOnline ( const cUUID a_UUID)
static

Returns true if the UUID is generated by online auth, false if it is an offline-generated UUID.

We use Version-3 UUIDs for offline UUIDs, online UUIDs are Version-4, thus we can tell them apart.

Definition at line 284 of file ClientHandle.cpp.

void cClientHandle::Kick ( const AString a_Reason)

Definition at line 296 of file ClientHandle.cpp.

void cClientHandle::OnError ( int  a_ErrorCode,
const AString a_ErrorMsg 
)
overrideprivatevirtual

Called when an error is detected on the connection.

Implements cTCPLink::cCallbacks.

Definition at line 3401 of file ClientHandle.cpp.

void cClientHandle::OnLinkCreated ( cTCPLinkPtr  a_Link)
overrideprivatevirtual

Called when the cTCPLink for the connection is created.

The callback may store the cTCPLink instance for later use, but it should remove it in OnError(), OnRemoteClosed() or right after Close().

Implements cTCPLink::cCallbacks.

Definition at line 3360 of file ClientHandle.cpp.

void cClientHandle::OnReceivedData ( const char *  a_Data,
size_t  a_Length 
)
overrideprivatevirtual

Called when there's data incoming from the remote peer.

Implements cTCPLink::cCallbacks.

Definition at line 3369 of file ClientHandle.cpp.

void cClientHandle::OnRemoteClosed ( void  )
overrideprivatevirtual

Called when the remote end closes the connection.

The link is still available for connection information query (IP / port). Sending data on the link is not an error, but the data won't be delivered.

Implements cTCPLink::cCallbacks.

Definition at line 3383 of file ClientHandle.cpp.

void cClientHandle::PacketBufferFull ( void  )

Definition at line 3261 of file ClientHandle.cpp.

void cClientHandle::PacketError ( UInt32  a_PacketType)

Definition at line 3285 of file ClientHandle.cpp.

void cClientHandle::PacketUnknown ( UInt32  a_PacketType)

Definition at line 3272 of file ClientHandle.cpp.

void cClientHandle::ProcessProtocolInOut ( void  )
private

Processes the data in the network input and output buffers.

Called by both Tick() and ServerTick().

Definition at line 3330 of file ClientHandle.cpp.

void cClientHandle::RegisterPluginChannels ( const AStringVector a_ChannelList)
private

Adds all of the channels to the list of current plugin channels.

Handles duplicates gracefully.

Definition at line 936 of file ClientHandle.cpp.

void cClientHandle::RemoveFromAllChunks ( void  )

Removes the client from all chunks.

Used when destroying the player. When switching worlds, RemoveFromWorld does this function's job so it isn't called.

Definition at line 643 of file ClientHandle.cpp.

void cClientHandle::RemoveFromWorld ( void  )

Called when the player moves into a different world.

Sends an UnloadChunk packet for each loaded chunk and resets the streamed chunks.

Definition at line 1999 of file ClientHandle.cpp.

void cClientHandle::SendAttachEntity ( const cEntity a_Entity,
const cEntity a_Vehicle 
)

Definition at line 2234 of file ClientHandle.cpp.

void cClientHandle::SendBlockAction ( int  a_BlockX,
int  a_BlockY,
int  a_BlockZ,
char  a_Byte1,
char  a_Byte2,
BLOCKTYPE  a_BlockType 
)

Definition at line 2261 of file ClientHandle.cpp.

void cClientHandle::SendBlockBreakAnim ( UInt32  a_EntityID,
int  a_BlockX,
int  a_BlockY,
int  a_BlockZ,
char  a_Stage 
)

Definition at line 2270 of file ClientHandle.cpp.

void cClientHandle::SendBlockChange ( int  a_BlockX,
int  a_BlockY,
int  a_BlockZ,
BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta 
)

Definition at line 2279 of file ClientHandle.cpp.

void cClientHandle::SendBlockChanges ( int  a_ChunkX,
int  a_ChunkZ,
const sSetBlockVector a_Changes 
)

Definition at line 2298 of file ClientHandle.cpp.

void cClientHandle::SendCameraSetTo ( const cEntity a_Entity)

Definition at line 2316 of file ClientHandle.cpp.

void cClientHandle::SendChat ( const AString a_Message,
eMessageType  a_ChatPrefix,
const AString a_AdditionalData = "" 
)

Definition at line 2325 of file ClientHandle.cpp.

void cClientHandle::SendChat ( const cCompositeChat a_Message)

Definition at line 2346 of file ClientHandle.cpp.

void cClientHandle::SendChatAboveActionBar ( const AString a_Message,
eMessageType  a_ChatPrefix,
const AString a_AdditionalData = "" 
)

Definition at line 2375 of file ClientHandle.cpp.

void cClientHandle::SendChatAboveActionBar ( const cCompositeChat a_Message)

Definition at line 2395 of file ClientHandle.cpp.

void cClientHandle::SendChatRaw ( const AString a_MessageRaw,
eChatType  a_Type 
)

Definition at line 2366 of file ClientHandle.cpp.

void cClientHandle::SendChatSystem ( const AString a_Message,
eMessageType  a_ChatPrefix,
const AString a_AdditionalData = "" 
)

Definition at line 2404 of file ClientHandle.cpp.

void cClientHandle::SendChatSystem ( const cCompositeChat a_Message)

Definition at line 2425 of file ClientHandle.cpp.

void cClientHandle::SendChunkData ( int  a_ChunkX,
int  a_ChunkZ,
cChunkDataSerializer a_Serializer 
)

Definition at line 2434 of file ClientHandle.cpp.

void cClientHandle::SendCollectEntity ( const cEntity a_Entity,
const cPlayer a_Player,
int  a_Count 
)

Definition at line 2476 of file ClientHandle.cpp.

void cClientHandle::SendData ( const char *  a_Data,
size_t  a_Size 
)

Definition at line 1983 of file ClientHandle.cpp.

void cClientHandle::SendDestroyEntity ( const cEntity a_Entity)

Definition at line 2485 of file ClientHandle.cpp.

void cClientHandle::SendDetachEntity ( const cEntity a_Entity,
const cEntity a_PreviousVehicle 
)

Definition at line 2494 of file ClientHandle.cpp.

void cClientHandle::SendDisconnect ( const AString a_Reason)

Definition at line 2503 of file ClientHandle.cpp.

void cClientHandle::SendDisplayObjective ( const AString a_Objective,
cScoreboard::eDisplaySlot  a_Display 
)

Definition at line 2927 of file ClientHandle.cpp.

void cClientHandle::SendEditSign ( int  a_BlockX,
int  a_BlockY,
int  a_BlockZ 
)

Definition at line 2523 of file ClientHandle.cpp.

void cClientHandle::SendEntityAnimation ( const cEntity a_Entity,
char  a_Animation 
)

Definition at line 2730 of file ClientHandle.cpp.

void cClientHandle::SendEntityEffect ( const cEntity a_Entity,
int  a_EffectID,
int  a_Amplifier,
int  a_Duration 
)

Definition at line 2533 of file ClientHandle.cpp.

void cClientHandle::SendEntityEquipment ( const cEntity a_Entity,
short  a_SlotNum,
const cItem a_Item 
)

Definition at line 2542 of file ClientHandle.cpp.

void cClientHandle::SendEntityHeadLook ( const cEntity a_Entity)

Definition at line 2551 of file ClientHandle.cpp.

void cClientHandle::SendEntityLook ( const cEntity a_Entity)

Definition at line 2562 of file ClientHandle.cpp.

void cClientHandle::SendEntityMetadata ( const cEntity a_Entity)

Definition at line 2573 of file ClientHandle.cpp.

void cClientHandle::SendEntityProperties ( const cEntity a_Entity)
void cClientHandle::SendEntityRelMove ( const cEntity a_Entity,
char  a_RelX,
char  a_RelY,
char  a_RelZ 
)

Definition at line 2582 of file ClientHandle.cpp.

void cClientHandle::SendEntityRelMoveLook ( const cEntity a_Entity,
char  a_RelX,
char  a_RelY,
char  a_RelZ 
)

Definition at line 2593 of file ClientHandle.cpp.

void cClientHandle::SendEntityStatus ( const cEntity a_Entity,
char  a_Status 
)

Definition at line 2604 of file ClientHandle.cpp.

void cClientHandle::SendEntityVelocity ( const cEntity a_Entity)

Definition at line 2613 of file ClientHandle.cpp.

void cClientHandle::SendExperience ( void  )

Definition at line 2891 of file ClientHandle.cpp.

void cClientHandle::SendExperienceOrb ( const cExpOrb a_ExpOrb)

Definition at line 2900 of file ClientHandle.cpp.

void cClientHandle::SendExplosion ( double  a_BlockX,
double  a_BlockY,
double  a_BlockZ,
float  a_Radius,
const cVector3iArray a_BlocksAffected,
const Vector3d a_PlayerMotion 
)

Definition at line 2622 of file ClientHandle.cpp.

void cClientHandle::SendGameMode ( eGameMode  a_GameMode)

Definition at line 2640 of file ClientHandle.cpp.

void cClientHandle::SendHealth ( void  )

Definition at line 2649 of file ClientHandle.cpp.

void cClientHandle::SendHeldItemChange ( int  a_ItemIndex)

Definition at line 2658 of file ClientHandle.cpp.

void cClientHandle::SendHideTitle ( void  )

Definition at line 2667 of file ClientHandle.cpp.

void cClientHandle::SendInventorySlot ( char  a_WindowID,
short  a_SlotNum,
const cItem a_Item 
)

Definition at line 2676 of file ClientHandle.cpp.

void cClientHandle::SendLeashEntity ( const cEntity a_Entity,
const cEntity a_EntityLeashedTo 
)

Definition at line 2243 of file ClientHandle.cpp.

void cClientHandle::SendMapData ( const cMap a_Map,
int  a_DataStartX,
int  a_DataStartY 
)

Definition at line 2685 of file ClientHandle.cpp.

void cClientHandle::SendPaintingSpawn ( const cPainting a_Painting)

Definition at line 2721 of file ClientHandle.cpp.

void cClientHandle::SendParticleEffect ( const AString a_ParticleName,
float  a_SrcX,
float  a_SrcY,
float  a_SrcZ,
float  a_OffsetX,
float  a_OffsetY,
float  a_OffsetZ,
float  a_ParticleData,
int  a_ParticleAmount 
)

Definition at line 2694 of file ClientHandle.cpp.

void cClientHandle::SendParticleEffect ( const AString a_ParticleName,
const Vector3f  a_Src,
const Vector3f  a_Offset,
float  a_ParticleData,
int  a_ParticleAmount,
std::array< int, 2 >  a_Data 
)

Definition at line 2703 of file ClientHandle.cpp.

void cClientHandle::SendPickupSpawn ( const cPickup a_Pickup)

Definition at line 2712 of file ClientHandle.cpp.

void cClientHandle::SendPlayerAbilities ( void  )

Definition at line 2739 of file ClientHandle.cpp.

void cClientHandle::SendPlayerListAddPlayer ( const cPlayer a_Player)

Definition at line 2748 of file ClientHandle.cpp.

void cClientHandle::SendPlayerListRemovePlayer ( const cPlayer a_Player)

Definition at line 2757 of file ClientHandle.cpp.

void cClientHandle::SendPlayerListUpdateDisplayName ( const cPlayer a_Player,
const AString a_CustomName 
)

Definition at line 2784 of file ClientHandle.cpp.

void cClientHandle::SendPlayerListUpdateGameMode ( const cPlayer a_Player)

Definition at line 2766 of file ClientHandle.cpp.

void cClientHandle::SendPlayerListUpdatePing ( const cPlayer a_Player)

Definition at line 2775 of file ClientHandle.cpp.

void cClientHandle::SendPlayerMaxSpeed ( void  )

Informs the client of the maximum player speed (1.6.1+)

Definition at line 2793 of file ClientHandle.cpp.

void cClientHandle::SendPlayerMoveLook ( void  )

Definition at line 2802 of file ClientHandle.cpp.

void cClientHandle::SendPlayerPosition ( void  )

Definition at line 2816 of file ClientHandle.cpp.

void cClientHandle::SendPlayerSpawn ( const cPlayer a_Player)

Definition at line 2825 of file ClientHandle.cpp.

void cClientHandle::SendPluginMessage ( const AString a_Channel,
const AString a_Message 
)

Definition at line 2844 of file ClientHandle.cpp.

void cClientHandle::SendRemoveEntityEffect ( const cEntity a_Entity,
int  a_EffectID 
)

Definition at line 2853 of file ClientHandle.cpp.

void cClientHandle::SendResetTitle ( void  )

Definition at line 2862 of file ClientHandle.cpp.

void cClientHandle::SendRespawn ( eDimension  a_Dimension,
bool  a_ShouldIgnoreDimensionChecks = false 
)

Definition at line 2871 of file ClientHandle.cpp.

void cClientHandle::SendScoreboardObjective ( const AString a_Name,
const AString a_DisplayName,
Byte  a_Mode 
)

Definition at line 2909 of file ClientHandle.cpp.

void cClientHandle::SendScoreUpdate ( const AString a_Objective,
const AString a_Player,
cObjective::Score  a_Score,
Byte  a_Mode 
)

Definition at line 2918 of file ClientHandle.cpp.

void cClientHandle::SendSetRawSubTitle ( const AString a_SubTitle)

Definition at line 2945 of file ClientHandle.cpp.

void cClientHandle::SendSetRawTitle ( const AString a_Title)

Definition at line 2963 of file ClientHandle.cpp.

void cClientHandle::SendSetSubTitle ( const cCompositeChat a_SubTitle)

Definition at line 2936 of file ClientHandle.cpp.

void cClientHandle::SendSetTitle ( const cCompositeChat a_Title)

Definition at line 2954 of file ClientHandle.cpp.

void cClientHandle::SendSoundEffect ( const AString a_SoundName,
double  a_X,
double  a_Y,
double  a_Z,
float  a_Volume,
float  a_Pitch 
)

Definition at line 2972 of file ClientHandle.cpp.

void cClientHandle::SendSoundEffect ( const AString a_SoundName,
Vector3d  a_Position,
float  a_Volume,
float  a_Pitch 
)

Definition at line 2982 of file ClientHandle.cpp.

void cClientHandle::SendSoundParticleEffect ( const EffectID  a_EffectID,
int  a_SrcX,
int  a_SrcY,
int  a_SrcZ,
int  a_Data 
)

Definition at line 2991 of file ClientHandle.cpp.

void cClientHandle::SendSpawnFallingBlock ( const cFallingBlock a_FallingBlock)

Definition at line 3000 of file ClientHandle.cpp.

void cClientHandle::SendSpawnMob ( const cMonster a_Mob)

Definition at line 3009 of file ClientHandle.cpp.

void cClientHandle::SendSpawnObject ( const cEntity a_Entity,
char  a_ObjectType,
int  a_ObjectData,
Byte  a_Yaw,
Byte  a_Pitch 
)

Definition at line 3018 of file ClientHandle.cpp.

void cClientHandle::SendSpawnVehicle ( const cEntity a_Vehicle,
char  a_VehicleType,
char  a_VehicleSubType = 0 
)

Definition at line 3027 of file ClientHandle.cpp.

void cClientHandle::SendStatistics ( const cStatManager a_Manager)

Definition at line 3036 of file ClientHandle.cpp.

void cClientHandle::SendTabCompletionResults ( const AStringVector a_Results)

Definition at line 3045 of file ClientHandle.cpp.

void cClientHandle::SendTeleportEntity ( const cEntity a_Entity)

Definition at line 3054 of file ClientHandle.cpp.

void cClientHandle::SendThunderbolt ( int  a_BlockX,
int  a_BlockY,
int  a_BlockZ 
)

Definition at line 3063 of file ClientHandle.cpp.

void cClientHandle::SendTimeUpdate ( Int64  a_WorldAge,
Int64  a_TimeOfDay,
bool  a_DoDaylightCycle 
)

Definition at line 3081 of file ClientHandle.cpp.

void cClientHandle::SendTitleTimes ( int  a_FadeInTicks,
int  a_DisplayTicks,
int  a_FadeOutTicks 
)

Definition at line 3072 of file ClientHandle.cpp.

void cClientHandle::SendUnleashEntity ( const cEntity a_Entity)

Definition at line 2252 of file ClientHandle.cpp.

void cClientHandle::SendUnloadChunk ( int  a_ChunkX,
int  a_ChunkZ 
)

Definition at line 3090 of file ClientHandle.cpp.

void cClientHandle::SendUpdateBlockEntity ( cBlockEntity a_BlockEntity)

Definition at line 3105 of file ClientHandle.cpp.

void cClientHandle::SendUpdateSign ( int  a_BlockX,
int  a_BlockY,
int  a_BlockZ,
const AString a_Line1,
const AString a_Line2,
const AString a_Line3,
const AString a_Line4 
)

Definition at line 3114 of file ClientHandle.cpp.

void cClientHandle::SendUseBed ( const cEntity a_Entity,
int  a_BlockX,
int  a_BlockY,
int  a_BlockZ 
)

Definition at line 3129 of file ClientHandle.cpp.

void cClientHandle::SendWeather ( eWeather  a_Weather)

Definition at line 3138 of file ClientHandle.cpp.

void cClientHandle::SendWholeInventory ( const cWindow a_Window)

Definition at line 3147 of file ClientHandle.cpp.

void cClientHandle::SendWindowClose ( const cWindow a_Window)

Definition at line 3156 of file ClientHandle.cpp.

void cClientHandle::SendWindowOpen ( const cWindow a_Window)

Definition at line 3165 of file ClientHandle.cpp.

void cClientHandle::SendWindowProperty ( const cWindow a_Window,
short  a_Property,
short  a_Value 
)

Definition at line 3174 of file ClientHandle.cpp.

void cClientHandle::ServerTick ( float  a_Dt)

Called while the client is being ticked from the cServer object.

Definition at line 2193 of file ClientHandle.cpp.

void cClientHandle::SetClientBrand ( const AString a_ClientBrand)
inline

Called by the protocol when it receives the MC|Brand plugin message.

Also callable by plugins. Simply stores the string value.

Definition at line 256 of file ClientHandle.h.

void cClientHandle::SetIPString ( const AString a_IPString)
inline

Sets the IP string that the client is using.

Overrides the IP string that was read from the socket. Used mainly by BungeeCord compatibility code.

Definition at line 73 of file ClientHandle.h.

void cClientHandle::SetIsForgeClient ( )
inline

Mark a client connection as using Forge.

Set by the protocol.

Definition at line 276 of file ClientHandle.h.

void cClientHandle::SetLocale ( const AString a_Locale)
inline

Definition at line 247 of file ClientHandle.h.

void cClientHandle::SetProperties ( const Json::Value &  a_Properties)
inline

Sets the player's properties, such as skin image and signature.

Used mainly by BungeeCord compatibility code - property querying is done on the BungeeCord server and the results are passed to MCS running in offline mode.

Definition at line 90 of file ClientHandle.h.

void cClientHandle::SetProtocolVersion ( UInt32  a_ProtocolVersion)
inline

Called by the protocol recognizer when the protocol version is known.

Definition at line 388 of file ClientHandle.h.

void cClientHandle::SetSelf ( cClientHandlePtr  a_Self)
private

Called right after the instance is created to store its SharedPtr inside.

Definition at line 3320 of file ClientHandle.cpp.

void cClientHandle::SetUsername ( const AString a_Username)

Definition at line 3192 of file ClientHandle.cpp.

void cClientHandle::SetUUID ( const cUUID a_UUID)
inline

Sets the player's UUID, as used by the protocol.

Used mainly by BungeeCord compatibility code - when authenticating is done on the BungeeCord server and the results are passed to MCS running in offline mode.

Definition at line 83 of file ClientHandle.h.

void cClientHandle::SetViewDistance ( int  a_ViewDistance)

Sets the maximal view distance.

Definition at line 3201 of file ClientHandle.cpp.

void cClientHandle::SocketClosed ( void  )
private

Called when the network socket has been closed.

Definition at line 3295 of file ClientHandle.cpp.

void cClientHandle::StreamChunk ( int  a_ChunkX,
int  a_ChunkZ,
cChunkSender::eChunkPriority  a_Priority 
)
private

Adds a single chunk to be streamed to the client; used by StreamChunks()

Definition at line 617 of file ClientHandle.cpp.

bool cClientHandle::StreamNextChunk ( void  )

This function sends a new unloaded chunk to the player.

Returns true if all chunks are loaded.

Definition at line 457 of file ClientHandle.cpp.

void cClientHandle::Tick ( float  a_Dt)

Called while the client is being ticked from the world via its cPlayer object.

Definition at line 2060 of file ClientHandle.cpp.

void cClientHandle::UnloadOutOfRangeChunks ( void  )

Remove all loaded chunks that are no longer in range.

Definition at line 568 of file ClientHandle.cpp.

void cClientHandle::UnregisterPluginChannels ( const AStringVector a_ChannelList)
private

Removes all of the channels from the list of current plugin channels.

Ignores channels that are not found.

Definition at line 948 of file ClientHandle.cpp.

bool cClientHandle::WantsSendChunk ( int  a_ChunkX,
int  a_ChunkZ 
)

Returns true if the client wants the chunk specified to be sent (in m_ChunksToSend)

Definition at line 3227 of file ClientHandle.cpp.

Friends And Related Function Documentation

friend class cForgeHandshake
friend

Definition at line 404 of file ClientHandle.h.

friend class cServer
friend

Definition at line 402 of file ClientHandle.h.

Member Data Documentation

const int cClientHandle::DEFAULT_VIEW_DISTANCE = 10
static

Definition at line 54 of file ClientHandle.h.

float cClientHandle::FASTBREAK_PERCENTAGE
static

The percentage how much a block has to be broken.

Should be a value between 0.7 (70% broken) and 1 (100% broken) depending on lag. Can be set in settings.ini [AntiCheat] FastBreakPercentage=(from 0 to 100)

Definition at line 62 of file ClientHandle.h.

int cClientHandle::m_BlockDigAnimSpeed
private

Definition at line 482 of file ClientHandle.h.

int cClientHandle::m_BlockDigAnimStage
private

Definition at line 481 of file ClientHandle.h.

int cClientHandle::m_BlockDigAnimX
private

Definition at line 483 of file ClientHandle.h.

int cClientHandle::m_BlockDigAnimY
private

Definition at line 484 of file ClientHandle.h.

int cClientHandle::m_BlockDigAnimZ
private

Definition at line 485 of file ClientHandle.h.

float cClientHandle::m_BreakProgress
private

Definition at line 559 of file ClientHandle.h.

cChunkCoords cClientHandle::m_CachedSentChunk
private

This is an optimization which saves you an iteration of m_SentChunks if you just want to know whether or not the player is standing at a sent chunk.

If this is equal to the coordinates of the chunk the player is currrently standing at, then this must be a sent chunk and a member of m_SentChunks. Otherwise, this contains an arbitrary value which should not be used.

Definition at line 460 of file ClientHandle.h.

std::unordered_set<cChunkCoords, cChunkCoordsHash> cClientHandle::m_ChunksToSend
private

Definition at line 429 of file ClientHandle.h.

AString cClientHandle::m_ClientBrand
private

The brand identification of the client, as received in the MC|Brand plugin message or set from a plugin.

Definition at line 547 of file ClientHandle.h.

Vector3d cClientHandle::m_ConfirmPosition
private

Definition at line 448 of file ClientHandle.h.

cCriticalSection cClientHandle::m_CSChunkLists
private

Definition at line 427 of file ClientHandle.h.

cCriticalSection cClientHandle::m_CSIncomingData
private

Protects m_IncomingData against multithreaded access.

Definition at line 435 of file ClientHandle.h.

cCriticalSection cClientHandle::m_CSOutgoingData
private

Protects m_OutgoingData against multithreaded access.

Definition at line 442 of file ClientHandle.h.

cCriticalSection cClientHandle::m_CSState
private

Definition at line 508 of file ClientHandle.h.

int cClientHandle::m_CurrentViewDistance
private

The actual view distance used, the minimum of client's requested view distance and world's max view distance.

Definition at line 416 of file ClientHandle.h.

cForgeHandshake cClientHandle::m_ForgeHandshake
private

Forge handshake state machine.

Definition at line 410 of file ClientHandle.h.

AStringMap cClientHandle::m_ForgeMods
private

Forge mods and versions installed on this client.

Definition at line 413 of file ClientHandle.h.

bool cClientHandle::m_HasSentDC
private

True if a Disconnect packet has been sent in either direction.

Definition at line 462 of file ClientHandle.h.

bool cClientHandle::m_HasSentPlayerChunk
private

Set to true when the chunk where the player is is sent to the client.

Used for spawning the player

Definition at line 535 of file ClientHandle.h.

bool cClientHandle::m_HasStartedDigging
private

Definition at line 488 of file ClientHandle.h.

AString cClientHandle::m_IncomingData
private

Queue for the incoming data received on the link until it is processed in Tick().

Protected by m_CSIncomingData.

Definition at line 439 of file ClientHandle.h.

AString cClientHandle::m_IPString
private

Definition at line 421 of file ClientHandle.h.

int cClientHandle::m_LastDigBlockX
private

Definition at line 489 of file ClientHandle.h.

int cClientHandle::m_LastDigBlockY
private

Definition at line 490 of file ClientHandle.h.

int cClientHandle::m_LastDigBlockZ
private

Definition at line 491 of file ClientHandle.h.

Vector3i cClientHandle::m_LastPlacedSign
private

The positions from the last sign that the player placed.

It's needed to verify the sign text change.

Definition at line 541 of file ClientHandle.h.

eDimension cClientHandle::m_LastSentDimension
private

The dimension that was last sent to a player in a Respawn or Login packet.

Used to avoid Respawning into the same dimension, which confuses the client.

Definition at line 400 of file ClientHandle.h.

int cClientHandle::m_LastStreamedChunkX
private

Definition at line 465 of file ClientHandle.h.

int cClientHandle::m_LastStreamedChunkZ
private

Definition at line 466 of file ClientHandle.h.

cTCPLinkPtr cClientHandle::m_Link
private

The link that is used for network communication.

m_CSOutgoingData is used to synchronize access for sending data.

Definition at line 554 of file ClientHandle.h.

std::unordered_set<cChunkCoords, cChunkCoordsHash> cClientHandle::m_LoadedChunks
private

Definition at line 428 of file ClientHandle.h.

AString cClientHandle::m_Locale
private

Client Settings.

Definition at line 538 of file ClientHandle.h.

int cClientHandle::m_NumBlockChangeInteractionsThisTick
private

Number of place or break interactions this tick.

Definition at line 524 of file ClientHandle.h.

int cClientHandle::m_NumExplosionsThisTick
private

Number of explosions sent this tick.

Definition at line 521 of file ClientHandle.h.

AString cClientHandle::m_OutgoingData
private

Buffer for storing outgoing data from any thread; will get sent in Tick() (to prevent deadlocks).

Protected by m_CSOutgoingData.

Definition at line 446 of file ClientHandle.h.

AString cClientHandle::m_Password
private

Definition at line 424 of file ClientHandle.h.

std::chrono::steady_clock::duration cClientHandle::m_Ping
private

Duration of the last completed client ping.

Definition at line 472 of file ClientHandle.h.

UInt32 cClientHandle::m_PingID
private

ID of the last ping request sent to the client.

Definition at line 475 of file ClientHandle.h.

std::chrono::steady_clock::time_point cClientHandle::m_PingStartTime
private

Time of the last ping request sent to the client.

Definition at line 478 of file ClientHandle.h.

cPlayer* cClientHandle::m_Player
private

Definition at line 450 of file ClientHandle.h.

std::unique_ptr<cPlayer> cClientHandle::m_PlayerPtr
private

Definition at line 453 of file ClientHandle.h.

cChannels cClientHandle::m_PluginChannels
private

The plugin channels that the client has registered.

Definition at line 544 of file ClientHandle.h.

Json::Value cClientHandle::m_Properties
private

Definition at line 425 of file ClientHandle.h.

std::unique_ptr<cProtocol> cClientHandle::m_Protocol
private

Definition at line 432 of file ClientHandle.h.

UInt32 cClientHandle::m_ProtocolVersion
private

The version of the protocol that the client is talking, or 0 if unknown.

Definition at line 550 of file ClientHandle.h.

int cClientHandle::m_RequestedViewDistance
private

The requested view distance from the player.

It isn't clamped with 1 and the max view distance of the world.

Definition at line 419 of file ClientHandle.h.

cClientHandlePtr cClientHandle::m_Self
private

Shared pointer to self, so that this instance can keep itself alive when needed.

Definition at line 557 of file ClientHandle.h.

cChunkCoordsList cClientHandle::m_SentChunks
private

Definition at line 430 of file ClientHandle.h.

bool cClientHandle::m_ShouldCheckDownloaded
private

If set to true during csDownloadingWorld, the tick thread calls CheckIfWorldDownloaded()

Definition at line 518 of file ClientHandle.h.

std::atomic<eState> cClientHandle::m_State
private

The current (networking) state of the client.

Protected from concurrent writes by m_CSState; but may be read by other threads concurrently. If a function depends on m_State or wants to change m_State, it needs to lock m_CSState. However, if it only uses m_State for a quick bail out, or it doesn't break if the client disconnects in the middle of it, it may just read m_State without locking m_CSState.

Definition at line 515 of file ClientHandle.h.

std::atomic<int> cClientHandle::m_TicksSinceLastPacket
private

Number of ticks since the last network packet was received (increased in Tick(), reset in OnReceivedData())

Definition at line 469 of file ClientHandle.h.

int cClientHandle::m_UniqueID
private

ID used for identification during authenticating.

Assigned sequentially for each new instance.

Definition at line 529 of file ClientHandle.h.

AString cClientHandle::m_Username
private

Definition at line 423 of file ClientHandle.h.

cUUID cClientHandle::m_UUID
private

Contains the UUID used by Mojang to identify the player's account.

Definition at line 532 of file ClientHandle.h.

const int cClientHandle::MAX_VIEW_DISTANCE = 32
static

Definition at line 56 of file ClientHandle.h.

const int cClientHandle::MIN_VIEW_DISTANCE = 1
static

Definition at line 57 of file ClientHandle.h.

int cClientHandle::s_ClientCount = 0
staticprivate

Definition at line 526 of file ClientHandle.h.


The documentation for this class was generated from the following files: