summaryrefslogtreecommitdiffstats
path: root/src/Protocol/Protocol16x.cpp
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-04-27 15:35:27 +0200
committerTycho <work.tycho+git@gmail.com>2014-04-27 15:35:27 +0200
commit57b8ee9163181920b634e475c781fe7764e11b98 (patch)
tree7d0675f8cda49a39b0b42eaaa928cfb66b57869a /src/Protocol/Protocol16x.cpp
parentImplemented Chunk Sparsing with segments (diff)
parentMerge pull request #863 from mc-server/chunkysparsing (diff)
downloadcuberite-57b8ee9163181920b634e475c781fe7764e11b98.tar
cuberite-57b8ee9163181920b634e475c781fe7764e11b98.tar.gz
cuberite-57b8ee9163181920b634e475c781fe7764e11b98.tar.bz2
cuberite-57b8ee9163181920b634e475c781fe7764e11b98.tar.lz
cuberite-57b8ee9163181920b634e475c781fe7764e11b98.tar.xz
cuberite-57b8ee9163181920b634e475c781fe7764e11b98.tar.zst
cuberite-57b8ee9163181920b634e475c781fe7764e11b98.zip
Diffstat (limited to 'src/Protocol/Protocol16x.cpp')
-rw-r--r--src/Protocol/Protocol16x.cpp55
1 files changed, 45 insertions, 10 deletions
diff --git a/src/Protocol/Protocol16x.cpp b/src/Protocol/Protocol16x.cpp
index ecb24254f..714bf5e46 100644
--- a/src/Protocol/Protocol16x.cpp
+++ b/src/Protocol/Protocol16x.cpp
@@ -18,6 +18,7 @@ Implements the 1.6.x protocol classes:
#include "../Entities/Entity.h"
#include "../Entities/Player.h"
#include "../UI/Window.h"
+#include "../CompositeChat.h"
@@ -89,6 +90,18 @@ void cProtocol161::SendChat(const AString & a_Message)
+void cProtocol161::SendChat(const cCompositeChat & a_Message)
+{
+ // This protocol version doesn't support composite messages to the full
+ // Just extract each part's text and use it:
+
+ super::SendChat(Printf("{\"text\":\"%s\"}", EscapeString(a_Message.ExtractText()).c_str()));
+}
+
+
+
+
+
void cProtocol161::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ)
{
cCSLock Lock(m_CSPacket);
@@ -118,9 +131,10 @@ void cProtocol161::SendHealth(void)
{
cCSLock Lock(m_CSPacket);
WriteByte (PACKET_UPDATE_HEALTH);
- WriteFloat((float)m_Client->GetPlayer()->GetHealth());
- WriteShort(m_Client->GetPlayer()->GetFoodLevel());
- WriteFloat((float)m_Client->GetPlayer()->GetFoodSaturationLevel());
+ cPlayer * Player = m_Client->GetPlayer();
+ WriteFloat((float)Player->GetHealth());
+ WriteShort((short)Player->GetFoodLevel());
+ WriteFloat((float)Player->GetFoodSaturationLevel());
Flush();
}
@@ -131,11 +145,12 @@ void cProtocol161::SendHealth(void)
void cProtocol161::SendPlayerMaxSpeed(void)
{
cCSLock Lock(m_CSPacket);
+ cPlayer * Player = m_Client->GetPlayer();
WriteByte(PACKET_ENTITY_PROPERTIES);
- WriteInt(m_Client->GetPlayer()->GetUniqueID());
+ WriteInt(Player->GetUniqueID());
WriteInt(1);
WriteString("generic.movementSpeed");
- WriteDouble(0.1 * m_Client->GetPlayer()->GetMaxSpeed());
+ WriteDouble(0.1 * Player->GetMaxSpeed());
Flush();
}
@@ -163,10 +178,10 @@ void cProtocol161::SendWindowOpen(const cWindow & a_Window)
}
cCSLock Lock(m_CSPacket);
WriteByte (PACKET_WINDOW_OPEN);
- WriteByte (a_Window.GetWindowID());
- WriteByte (a_Window.GetWindowType());
+ WriteChar (a_Window.GetWindowID());
+ WriteByte ((Byte)a_Window.GetWindowType());
WriteString(a_Window.GetWindowTitle());
- WriteByte (a_Window.GetNumNonInventorySlots());
+ WriteByte ((Byte)a_Window.GetNumNonInventorySlots());
WriteByte (1); // Use title
if (a_Window.GetWindowType() == cWindow::wtAnimalChest)
{
@@ -201,6 +216,25 @@ int cProtocol161::ParseEntityAction(void)
+int cProtocol161::ParseLogin(void)
+{
+ // The login packet is sent by Forge clients only
+ // Only parse the packet, do no extra processing
+ // Note that the types and the names have been only guessed and are not verified at all!
+ HANDLE_PACKET_READ(ReadBEInt, int, Int1);
+ HANDLE_PACKET_READ(ReadBEUTF16String16, AString, String1);
+ HANDLE_PACKET_READ(ReadChar, char, Char1);
+ HANDLE_PACKET_READ(ReadChar, char, Char2);
+ HANDLE_PACKET_READ(ReadChar, char, Char3);
+ HANDLE_PACKET_READ(ReadByte, Byte, Byte1);
+ HANDLE_PACKET_READ(ReadByte, Byte, Byte2);
+ return PARSE_OK;
+}
+
+
+
+
+
int cProtocol161::ParsePlayerAbilities(void)
{
HANDLE_PACKET_READ(ReadByte, Byte, Flags);
@@ -263,11 +297,12 @@ cProtocol162::cProtocol162(cClientHandle * a_Client) :
void cProtocol162::SendPlayerMaxSpeed(void)
{
cCSLock Lock(m_CSPacket);
+ cPlayer * Player = m_Client->GetPlayer();
WriteByte(PACKET_ENTITY_PROPERTIES);
- WriteInt(m_Client->GetPlayer()->GetUniqueID());
+ WriteInt(Player->GetUniqueID());
WriteInt(1);
WriteString("generic.movementSpeed");
- WriteDouble(0.1 * m_Client->GetPlayer()->GetMaxSpeed());
+ WriteDouble(0.1 * Player->GetMaxSpeed());
WriteShort(0);
Flush();
}