Added temporary block type mapping for 1.13+ protocols.
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user