summaryrefslogtreecommitdiffstats
path: root/src/Protocol/Protocol_1_13.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2020-01-03 17:31:13 +0100
committerMattes D <github@xoft.cz>2020-01-07 06:53:17 +0100
commit4aef80b47eb6941d7fc41e57efe147af0ece1f9b (patch)
tree4aeb7c9e8e4aa3ae2ceed1cc60155d868852c5cd /src/Protocol/Protocol_1_13.cpp
parentStringUtils: Added note to StringsConcat about StringJoin. (diff)
downloadcuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.gz
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.bz2
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.lz
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.xz
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.zst
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.zip
Diffstat (limited to '')
-rw-r--r--src/Protocol/Protocol_1_13.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/Protocol/Protocol_1_13.cpp b/src/Protocol/Protocol_1_13.cpp
index f84e8d1bd..e2cd72693 100644
--- a/src/Protocol/Protocol_1_13.cpp
+++ b/src/Protocol/Protocol_1_13.cpp
@@ -11,6 +11,7 @@ Implements the 1.13 protocol classes:
#include "ProtocolRecognizer.h"
#include "ChunkDataSerializer.h"
#include "Packetizer.h"
+#include "ProtocolPalettes.h"
#include "../Entities/Boat.h"
#include "../Entities/Minecart.h"
@@ -21,9 +22,11 @@ Implements the 1.13 protocol classes:
#include "../Entities/FireworkEntity.h"
#include "../Entities/SplashPotionEntity.h"
+#include "../BlockTypePalette.h"
+#include "../ClientHandle.h"
#include "../Root.h"
#include "../Server.h"
-#include "../ClientHandle.h"
+
#include "../Bindings/PluginManager.h"
@@ -69,6 +72,25 @@ cProtocol_1_13::cProtocol_1_13(cClientHandle * a_Client, const AString & a_Serve
+void cProtocol_1_13::Initialize(cClientHandle & a_Client)
+{
+ // Get the palettes; fail if not available:
+ auto paletteVersion = this->GetPaletteVersion();
+ m_BlockTypePalette = cRoot::Get()->GetProtocolPalettes().blockTypePalette(paletteVersion);
+ if (m_BlockTypePalette == nullptr)
+ {
+ throw std::runtime_error(Printf("This server doesn't support protocol %s.", paletteVersion));
+ }
+
+ // Process the palette into the temporary BLOCKTYPE -> NetBlockID map:
+ auto upg = cRoot::Get()->GetUpgradeBlockTypePalette();
+ m_BlockTypeMap = m_BlockTypePalette->createTransformMapWithFallback(upg, 0);
+}
+
+
+
+
+
UInt32 cProtocol_1_13::GetPacketID(ePacketType a_PacketType)
{
switch (a_PacketType)
@@ -132,6 +154,15 @@ UInt32 cProtocol_1_13::GetPacketID(ePacketType a_PacketType)
+AString cProtocol_1_13::GetPaletteVersion() const
+{
+ return "1.13";
+}
+
+
+
+
+
bool cProtocol_1_13::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
{
if (m_State != 3)
@@ -292,7 +323,7 @@ void cProtocol_1_13::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSeriali
{
ASSERT(m_State == 3); // In game mode?
- const AString & ChunkData = a_Serializer.Serialize(cChunkDataSerializer::RELEASE_1_13, a_ChunkX, a_ChunkZ);
+ const AString & ChunkData = a_Serializer.Serialize(cChunkDataSerializer::RELEASE_1_13, a_ChunkX, a_ChunkZ, m_BlockTypeMap);
cCSLock Lock(m_CSPacket);
SendData(ChunkData.data(), ChunkData.size());
}