summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/Protocol')
-rw-r--r--src/Protocol/Palettes/Palette_1_13.cpp66
-rw-r--r--src/Protocol/Palettes/Palette_1_13.h2
-rw-r--r--src/Protocol/Palettes/Palette_1_13_1.cpp72
-rw-r--r--src/Protocol/Palettes/Palette_1_13_1.h2
-rw-r--r--src/Protocol/Palettes/Palette_1_14.cpp83
-rw-r--r--src/Protocol/Palettes/Palette_1_14.h2
-rw-r--r--src/Protocol/Protocol_1_13.cpp58
-rw-r--r--src/Protocol/Protocol_1_13.h2
-rw-r--r--src/Protocol/Protocol_1_14.cpp9
-rw-r--r--src/Protocol/Protocol_1_14.h1
-rw-r--r--src/Protocol/Protocol_1_8.cpp130
-rw-r--r--src/Protocol/Protocol_1_8.h8
-rw-r--r--src/Protocol/Protocol_1_9.cpp1
13 files changed, 413 insertions, 23 deletions
diff --git a/src/Protocol/Palettes/Palette_1_13.cpp b/src/Protocol/Palettes/Palette_1_13.cpp
index d04bc3180..7950ee72e 100644
--- a/src/Protocol/Palettes/Palette_1_13.cpp
+++ b/src/Protocol/Palettes/Palette_1_13.cpp
@@ -5,7 +5,7 @@
namespace Palette_1_13
{
- UInt32 FromBlock(short ID)
+ UInt32 FromBlock(const short ID)
{
using namespace Block;
@@ -7067,7 +7067,7 @@ namespace Palette_1_13
}
}
- UInt32 FromItem(Item ID)
+ UInt32 FromItem(const Item ID)
{
switch (ID)
{
@@ -7860,7 +7860,67 @@ namespace Palette_1_13
}
}
- Item ToItem(UInt32 ID)
+ UInt32 From(const Statistic ID)
+ {
+ switch (ID)
+ {
+ case Statistic::AnimalsBred: return 25;
+ case Statistic::AviateOneCm: return 17;
+ case Statistic::BoatOneCm: return 14;
+ case Statistic::CleanArmor: return 33;
+ case Statistic::CleanBanner: return 34;
+ case Statistic::ClimbOneCm: return 10;
+ case Statistic::CrouchOneCm: return 6;
+ case Statistic::DamageDealt: return 21;
+ case Statistic::DamageTaken: return 22;
+ case Statistic::Deaths: return 23;
+ case Statistic::Drop: return 20;
+ case Statistic::EatCakeSlice: return 30;
+ case Statistic::EnchantItem: return 45;
+ case Statistic::FallOneCm: return 9;
+ case Statistic::FillCauldron: return 31;
+ case Statistic::FishCaught: return 27;
+ case Statistic::FlyOneCm: return 11;
+ case Statistic::HorseOneCm: return 16;
+ case Statistic::InspectDispenser: return 39;
+ case Statistic::InspectDropper: return 37;
+ case Statistic::InspectHopper: return 38;
+ case Statistic::InteractWithBeacon: return 36;
+ case Statistic::InteractWithBrewingstand: return 35;
+ case Statistic::InteractWithCraftingTable: return 48;
+ case Statistic::InteractWithFurnace: return 47;
+ case Statistic::Jump: return 19;
+ case Statistic::LeaveGame: return 0;
+ case Statistic::MinecartOneCm: return 13;
+ case Statistic::MobKills: return 24;
+ case Statistic::OpenChest: return 49;
+ case Statistic::OpenEnderchest: return 44;
+ case Statistic::OpenShulkerBox: return 51;
+ case Statistic::PigOneCm: return 15;
+ case Statistic::PlayerKills: return 26;
+ case Statistic::PlayNoteblock: return 40;
+ case Statistic::PlayOneMinute: return 1;
+ case Statistic::PlayRecord: return 46;
+ case Statistic::PotFlower: return 42;
+ case Statistic::SleepInBed: return 50;
+ case Statistic::SneakTime: return 4;
+ case Statistic::SprintOneCm: return 7;
+ case Statistic::SwimOneCm: return 8;
+ case Statistic::TalkedToVillager: return 28;
+ case Statistic::TimeSinceDeath: return 2;
+ case Statistic::TimeSinceRest: return 3;
+ case Statistic::TradedWithVillager: return 29;
+ case Statistic::TriggerTrappedChest: return 43;
+ case Statistic::TuneNoteblock: return 41;
+ case Statistic::UseCauldron: return 32;
+ case Statistic::WalkOneCm: return 5;
+ case Statistic::WalkOnWaterOneCm: return 18;
+ case Statistic::WalkUnderWaterOneCm: return 12;
+ default: return -1;
+ }
+ }
+
+ Item ToItem(const UInt32 ID)
{
switch (ID)
{
diff --git a/src/Protocol/Palettes/Palette_1_13.h b/src/Protocol/Palettes/Palette_1_13.h
index eade92688..3f72e0277 100644
--- a/src/Protocol/Palettes/Palette_1_13.h
+++ b/src/Protocol/Palettes/Palette_1_13.h
@@ -1,10 +1,12 @@
#pragma once
#include "../../Registries/Items.h"
+#include "../../Registries/Statistics.h"
namespace Palette_1_13
{
UInt32 FromBlock(short ID);
UInt32 FromItem(Item ID);
+ UInt32 From(Statistic ID);
Item ToItem(UInt32 ID);
}
diff --git a/src/Protocol/Palettes/Palette_1_13_1.cpp b/src/Protocol/Palettes/Palette_1_13_1.cpp
index f8cddcaed..25f02e47b 100644
--- a/src/Protocol/Palettes/Palette_1_13_1.cpp
+++ b/src/Protocol/Palettes/Palette_1_13_1.cpp
@@ -5,7 +5,7 @@
namespace Palette_1_13_1
{
- UInt32 FromBlock(short ID)
+ UInt32 FromBlock(const short ID)
{
using namespace Block;
@@ -7072,7 +7072,7 @@ namespace Palette_1_13_1
}
}
- UInt32 FromItem(Item ID)
+ UInt32 FromItem(const Item ID)
{
switch (ID)
{
@@ -7870,7 +7870,73 @@ namespace Palette_1_13_1
}
}
- Item ToItem(UInt32 ID)
+ UInt32 From(const Statistic ID)
+ {
+ switch (ID)
+ {
+ case Statistic::AnimalsBred: return 30;
+ case Statistic::AviateOneCm: return 17;
+ case Statistic::BoatOneCm: return 14;
+ case Statistic::CleanArmor: return 38;
+ case Statistic::CleanBanner: return 39;
+ case Statistic::CleanShulkerBox: return 40;
+ case Statistic::ClimbOneCm: return 10;
+ case Statistic::CrouchOneCm: return 6;
+ case Statistic::DamageAbsorbed: return 26;
+ case Statistic::DamageBlockedByShield: return 25;
+ case Statistic::DamageDealt: return 21;
+ case Statistic::DamageDealtAbsorbed: return 22;
+ case Statistic::DamageDealtResisted: return 23;
+ case Statistic::DamageResisted: return 27;
+ case Statistic::DamageTaken: return 24;
+ case Statistic::Deaths: return 28;
+ case Statistic::Drop: return 20;
+ case Statistic::EatCakeSlice: return 35;
+ case Statistic::EnchantItem: return 51;
+ case Statistic::FallOneCm: return 9;
+ case Statistic::FillCauldron: return 36;
+ case Statistic::FishCaught: return 32;
+ case Statistic::FlyOneCm: return 11;
+ case Statistic::HorseOneCm: return 16;
+ case Statistic::InspectDispenser: return 45;
+ case Statistic::InspectDropper: return 43;
+ case Statistic::InspectHopper: return 44;
+ case Statistic::InteractWithBeacon: return 42;
+ case Statistic::InteractWithBrewingstand: return 41;
+ case Statistic::InteractWithCraftingTable: return 54;
+ case Statistic::InteractWithFurnace: return 53;
+ case Statistic::Jump: return 19;
+ case Statistic::LeaveGame: return 0;
+ case Statistic::MinecartOneCm: return 13;
+ case Statistic::MobKills: return 29;
+ case Statistic::OpenChest: return 55;
+ case Statistic::OpenEnderchest: return 50;
+ case Statistic::OpenShulkerBox: return 57;
+ case Statistic::PigOneCm: return 15;
+ case Statistic::PlayerKills: return 31;
+ case Statistic::PlayNoteblock: return 46;
+ case Statistic::PlayOneMinute: return 1;
+ case Statistic::PlayRecord: return 52;
+ case Statistic::PotFlower: return 48;
+ case Statistic::SleepInBed: return 56;
+ case Statistic::SneakTime: return 4;
+ case Statistic::SprintOneCm: return 7;
+ case Statistic::SwimOneCm: return 8;
+ case Statistic::TalkedToVillager: return 33;
+ case Statistic::TimeSinceDeath: return 2;
+ case Statistic::TimeSinceRest: return 3;
+ case Statistic::TradedWithVillager: return 34;
+ case Statistic::TriggerTrappedChest: return 49;
+ case Statistic::TuneNoteblock: return 47;
+ case Statistic::UseCauldron: return 37;
+ case Statistic::WalkOneCm: return 5;
+ case Statistic::WalkOnWaterOneCm: return 18;
+ case Statistic::WalkUnderWaterOneCm: return 12;
+ default: return -1;
+ }
+ }
+
+ Item ToItem(const UInt32 ID)
{
switch (ID)
{
diff --git a/src/Protocol/Palettes/Palette_1_13_1.h b/src/Protocol/Palettes/Palette_1_13_1.h
index a973b0f5d..2e01fef49 100644
--- a/src/Protocol/Palettes/Palette_1_13_1.h
+++ b/src/Protocol/Palettes/Palette_1_13_1.h
@@ -1,10 +1,12 @@
#pragma once
#include "../../Registries/Items.h"
+#include "../../Registries/Statistics.h"
namespace Palette_1_13_1
{
UInt32 FromBlock(short ID);
UInt32 FromItem(Item ID);
+ UInt32 From(Statistic ID);
Item ToItem(UInt32 ID);
}
diff --git a/src/Protocol/Palettes/Palette_1_14.cpp b/src/Protocol/Palettes/Palette_1_14.cpp
index d03ae7982..e98234ff2 100644
--- a/src/Protocol/Palettes/Palette_1_14.cpp
+++ b/src/Protocol/Palettes/Palette_1_14.cpp
@@ -5,7 +5,7 @@
namespace Palette_1_14
{
- UInt32 FromBlock(short ID)
+ UInt32 FromBlock(const short ID)
{
using namespace Block;
@@ -8620,7 +8620,7 @@ namespace Palette_1_14
}
}
- UInt32 FromItem(Item ID)
+ UInt32 FromItem(const Item ID)
{
switch (ID)
{
@@ -9505,7 +9505,84 @@ namespace Palette_1_14
}
}
- Item ToItem(UInt32 ID)
+ UInt32 From(const Statistic ID)
+ {
+ switch (ID)
+ {
+ case Statistic::AnimalsBred: return 30;
+ case Statistic::AviateOneCm: return 17;
+ case Statistic::BellRing: return 66;
+ case Statistic::BoatOneCm: return 14;
+ case Statistic::CleanArmor: return 38;
+ case Statistic::CleanBanner: return 39;
+ case Statistic::CleanShulkerBox: return 40;
+ case Statistic::ClimbOneCm: return 10;
+ case Statistic::CrouchOneCm: return 6;
+ case Statistic::DamageAbsorbed: return 26;
+ case Statistic::DamageBlockedByShield: return 25;
+ case Statistic::DamageDealt: return 21;
+ case Statistic::DamageDealtAbsorbed: return 22;
+ case Statistic::DamageDealtResisted: return 23;
+ case Statistic::DamageResisted: return 27;
+ case Statistic::DamageTaken: return 24;
+ case Statistic::Deaths: return 28;
+ case Statistic::Drop: return 20;
+ case Statistic::EatCakeSlice: return 35;
+ case Statistic::EnchantItem: return 51;
+ case Statistic::FallOneCm: return 9;
+ case Statistic::FillCauldron: return 36;
+ case Statistic::FishCaught: return 32;
+ case Statistic::FlyOneCm: return 11;
+ case Statistic::HorseOneCm: return 16;
+ case Statistic::InspectDispenser: return 45;
+ case Statistic::InspectDropper: return 43;
+ case Statistic::InspectHopper: return 44;
+ case Statistic::InteractWithBeacon: return 42;
+ case Statistic::InteractWithBlastFurnace: return 59;
+ case Statistic::InteractWithBrewingstand: return 41;
+ case Statistic::InteractWithCampfire: return 62;
+ case Statistic::InteractWithCartographyTable: return 63;
+ case Statistic::InteractWithCraftingTable: return 54;
+ case Statistic::InteractWithFurnace: return 53;
+ case Statistic::InteractWithLectern: return 61;
+ case Statistic::InteractWithLoom: return 64;
+ case Statistic::InteractWithSmoker: return 60;
+ case Statistic::InteractWithStonecutter: return 65;
+ case Statistic::Jump: return 19;
+ case Statistic::LeaveGame: return 0;
+ case Statistic::MinecartOneCm: return 13;
+ case Statistic::MobKills: return 29;
+ case Statistic::OpenBarrel: return 58;
+ case Statistic::OpenChest: return 55;
+ case Statistic::OpenEnderchest: return 50;
+ case Statistic::OpenShulkerBox: return 57;
+ case Statistic::PigOneCm: return 15;
+ case Statistic::PlayerKills: return 31;
+ case Statistic::PlayNoteblock: return 46;
+ case Statistic::PlayOneMinute: return 1;
+ case Statistic::PlayRecord: return 52;
+ case Statistic::PotFlower: return 48;
+ case Statistic::RaidTrigger: return 67;
+ case Statistic::RaidWin: return 68;
+ case Statistic::SleepInBed: return 56;
+ case Statistic::SneakTime: return 4;
+ case Statistic::SprintOneCm: return 7;
+ case Statistic::SwimOneCm: return 18;
+ case Statistic::TalkedToVillager: return 33;
+ case Statistic::TimeSinceDeath: return 2;
+ case Statistic::TimeSinceRest: return 3;
+ case Statistic::TradedWithVillager: return 34;
+ case Statistic::TriggerTrappedChest: return 49;
+ case Statistic::TuneNoteblock: return 47;
+ case Statistic::UseCauldron: return 37;
+ case Statistic::WalkOneCm: return 5;
+ case Statistic::WalkOnWaterOneCm: return 8;
+ case Statistic::WalkUnderWaterOneCm: return 12;
+ default: return -1;
+ }
+ }
+
+ Item ToItem(const UInt32 ID)
{
switch (ID)
{
diff --git a/src/Protocol/Palettes/Palette_1_14.h b/src/Protocol/Palettes/Palette_1_14.h
index 852dce6bd..1bb5ffa85 100644
--- a/src/Protocol/Palettes/Palette_1_14.h
+++ b/src/Protocol/Palettes/Palette_1_14.h
@@ -1,10 +1,12 @@
#pragma once
#include "../../Registries/Items.h"
+#include "../../Registries/Statistics.h"
namespace Palette_1_14
{
UInt32 FromBlock(short ID);
UInt32 FromItem(Item ID);
+ UInt32 From(Statistic ID);
Item ToItem(UInt32 ID);
}
diff --git a/src/Protocol/Protocol_1_13.cpp b/src/Protocol/Protocol_1_13.cpp
index 94dc39ea9..f0f2312d2 100644
--- a/src/Protocol/Protocol_1_13.cpp
+++ b/src/Protocol/Protocol_1_13.cpp
@@ -155,7 +155,45 @@ void cProtocol_1_13::SendScoreboardObjective(const AString & a_Name, const AStri
void cProtocol_1_13::SendStatistics(const cStatManager & a_Manager)
{
- // TODO
+ ASSERT(m_State == 3); // In game mode?
+
+ UInt32 Size = 0;
+ a_Manager.ForEachStatisticType([this, &Size](const auto & Store)
+ {
+ for (const auto & Item : Store)
+ {
+ // Client balks at out-of-range values so there is no good default value
+ // We're forced to not send the statistics this protocol version doesn't support
+
+ if (GetProtocolStatisticType(Item.first) != static_cast<UInt32>(-1))
+ {
+ Size++;
+ }
+ }
+ });
+
+ // No need to check Size != 0
+ // Assume that the vast majority of the time there's at least one statistic to send
+
+ cPacketizer Pkt(*this, pktStatistics);
+ Pkt.WriteVarInt32(Size);
+
+ a_Manager.ForEachStatisticType([this, &Pkt](const cStatManager::CustomStore & Store)
+ {
+ for (const auto & Item : Store)
+ {
+ const auto ID = GetProtocolStatisticType(Item.first);
+ if (ID == static_cast<UInt32>(-1))
+ {
+ // Unsupported, don't send:
+ continue;
+ }
+
+ Pkt.WriteVarInt32(8); // "Custom" category
+ Pkt.WriteVarInt32(ID);
+ Pkt.WriteVarInt32(static_cast<UInt32>(Item.second));
+ }
+ });
}
@@ -563,6 +601,15 @@ UInt32 cProtocol_1_13::GetProtocolIDFromItem(short a_ItemID, short a_ItemDamage)
+UInt32 cProtocol_1_13::GetProtocolStatisticType(Statistic a_Statistic)
+{
+ return Palette_1_13::From(a_Statistic);
+}
+
+
+
+
+
bool cProtocol_1_13::ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item, size_t a_KeepRemainingBytes)
{
HANDLE_PACKET_READ(a_ByteBuffer, ReadBEInt16, Int16, ItemID);
@@ -1210,6 +1257,15 @@ UInt32 cProtocol_1_13_1::GetProtocolIDFromItem(short a_ItemID, short a_ItemDamag
+UInt32 cProtocol_1_13_1::GetProtocolStatisticType(Statistic a_Statistic)
+{
+ return Palette_1_13_1::From(a_Statistic);
+}
+
+
+
+
+
////////////////////////////////////////////////////////////////////////////////
// cProtocol_1_13_2:
diff --git a/src/Protocol/Protocol_1_13.h b/src/Protocol/Protocol_1_13.h
index bdc8bb33a..a15b359cc 100644
--- a/src/Protocol/Protocol_1_13.h
+++ b/src/Protocol/Protocol_1_13.h
@@ -79,6 +79,7 @@ protected:
virtual UInt8 GetEntityMetadataID(eEntityMetadataType a_FieldType);
virtual std::pair<short, short> GetItemFromProtocolID(UInt32 a_ProtocolID);
virtual UInt32 GetProtocolIDFromItem(short a_ItemID, short a_ItemDamage);
+ virtual UInt32 GetProtocolStatisticType(Statistic a_Statistic);
virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) override;
virtual void HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer) override;
@@ -111,6 +112,7 @@ protected:
virtual Version GetProtocolVersion() override;
virtual std::pair<short, short> GetItemFromProtocolID(UInt32 a_ProtocolID) override;
virtual UInt32 GetProtocolIDFromItem(short a_ItemID, short a_ItemDamage) override;
+ virtual UInt32 GetProtocolStatisticType(Statistic a_Statistic) override;
};
diff --git a/src/Protocol/Protocol_1_14.cpp b/src/Protocol/Protocol_1_14.cpp
index d6751c6b1..3222e7fe2 100644
--- a/src/Protocol/Protocol_1_14.cpp
+++ b/src/Protocol/Protocol_1_14.cpp
@@ -303,3 +303,12 @@ UInt32 cProtocol_1_14::GetProtocolIDFromItem(short a_ItemID, short a_ItemDamage)
{
return Palette_1_14::FromItem(PaletteUpgrade::FromItem(a_ItemID, a_ItemDamage));
}
+
+
+
+
+
+UInt32 cProtocol_1_14::GetProtocolStatisticType(Statistic a_Statistic)
+{
+ return Palette_1_14::From(a_Statistic);
+}
diff --git a/src/Protocol/Protocol_1_14.h b/src/Protocol/Protocol_1_14.h
index 2b21246e5..8a80d0bee 100644
--- a/src/Protocol/Protocol_1_14.h
+++ b/src/Protocol/Protocol_1_14.h
@@ -53,6 +53,7 @@ protected:
virtual std::pair<short, short> GetItemFromProtocolID(UInt32 a_ProtocolID) override;
virtual UInt32 GetProtocolIDFromItem(short a_ItemID, short a_ItemDamage) override;
+ virtual UInt32 GetProtocolStatisticType(Statistic a_Statistic) override;
virtual void WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_Entity) override {}
virtual void WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) override {}
diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp
index e865725ea..3474ed718 100644
--- a/src/Protocol/Protocol_1_8.cpp
+++ b/src/Protocol/Protocol_1_8.cpp
@@ -19,7 +19,6 @@ Implements the 1.8 protocol classes:
#include "../EffectID.h"
#include "../StringCompression.h"
#include "../CompositeChat.h"
-#include "../Statistics.h"
#include "../UUID.h"
#include "../World.h"
#include "../JsonUtils.h"
@@ -1421,18 +1420,26 @@ void cProtocol_1_8_0::SendStatistics(const cStatManager & a_Manager)
{
ASSERT(m_State == 3); // In game mode?
+ UInt32 Size = 0;
+ a_Manager.ForEachStatisticType([&Size](const auto & Store)
+ {
+ Size += static_cast<UInt32>(Store.size());
+ });
+
+ // No need to check Size != 0
+ // Assume that the vast majority of the time there's at least one statistic to send
+
cPacketizer Pkt(*this, pktStatistics);
- Pkt.WriteVarInt32(statCount); // TODO 2014-05-11 xdot: Optimization: Send "dirty" statistics only
+ Pkt.WriteVarInt32(Size);
- size_t Count = static_cast<size_t>(statCount);
- for (size_t i = 0; i < Count; ++i)
+ a_Manager.ForEachStatisticType([&Pkt](const cStatManager::CustomStore & Store)
{
- StatValue Value = a_Manager.GetValue(static_cast<eStatistic>(i));
- const AString & StatName = cStatInfo::GetName(static_cast<eStatistic>(i));
-
- Pkt.WriteString(StatName);
- Pkt.WriteVarInt32(static_cast<UInt32>(Value));
- }
+ for (const auto & Item : Store)
+ {
+ Pkt.WriteString(GetProtocolStatisticName(Item.first));
+ Pkt.WriteVarInt32(static_cast<UInt32>(Item.second));
+ }
+ });
}
@@ -2565,7 +2572,7 @@ void cProtocol_1_8_0::HandlePacketClientStatus(cByteBuffer & a_ByteBuffer)
case 2:
{
// Open Inventory achievement
- m_Client->GetPlayer()->AwardAchievement(achOpenInv);
+ m_Client->GetPlayer()->AwardAchievement(Statistic::AchOpenInventory);
break;
}
}
@@ -3968,3 +3975,104 @@ UInt8 cProtocol_1_8_0::GetProtocolEntityType(const cEntity & a_Entity)
}
UNREACHABLE("Unhandled entity kind");
}
+
+
+
+
+
+const char * cProtocol_1_8_0::GetProtocolStatisticName(Statistic a_Statistic)
+{
+ switch (a_Statistic)
+ {
+ // V1.8 Achievements
+ case Statistic::AchOpenInventory: return "achievement.openInventory";
+ case Statistic::AchMineWood: return "achievement.mineWood";
+ case Statistic::AchBuildWorkBench: return "achievement.buildWorkBench";
+ case Statistic::AchBuildPickaxe: return "achievement.buildPickaxe";
+ case Statistic::AchBuildFurnace: return "achievement.buildFurnace";
+ case Statistic::AchAcquireIron: return "achievement.acquireIron";
+ case Statistic::AchBuildHoe: return "achievement.buildHoe";
+ case Statistic::AchMakeBread: return "achievement.makeBread";
+ case Statistic::AchBakeCake: return "achievement.bakeCake";
+ case Statistic::AchBuildBetterPickaxe: return "achievement.buildBetterPickaxe";
+ case Statistic::AchCookFish: return "achievement.cookFish";
+ case Statistic::AchOnARail: return "achievement.onARail";
+ case Statistic::AchBuildSword: return "achievement.buildSword";
+ case Statistic::AchKillEnemy: return "achievement.killEnemy";
+ case Statistic::AchKillCow: return "achievement.killCow";
+ case Statistic::AchFlyPig: return "achievement.flyPig";
+ case Statistic::AchSnipeSkeleton: return "achievement.snipeSkeleton";
+ case Statistic::AchDiamonds: return "achievement.diamonds";
+ case Statistic::AchPortal: return "achievement.portal";
+ case Statistic::AchGhast: return "achievement.ghast";
+ case Statistic::AchBlazeRod: return "achievement.blazeRod";
+ case Statistic::AchPotion: return "achievement.potion";
+ case Statistic::AchTheEnd: return "achievement.theEnd";
+ case Statistic::AchTheEnd2: return "achievement.theEnd2";
+ case Statistic::AchEnchantments: return "achievement.enchantments";
+ case Statistic::AchOverkill: return "achievement.overkill";
+ case Statistic::AchBookcase: return "achievement.bookcase";
+ case Statistic::AchExploreAllBiomes: return "achievement.exploreAllBiomes";
+ case Statistic::AchSpawnWither: return "achievement.spawnWither";
+ case Statistic::AchKillWither: return "achievement.killWither";
+ case Statistic::AchFullBeacon: return "achievement.fullBeacon";
+ case Statistic::AchBreedCow: return "achievement.breedCow";
+ case Statistic::AchDiamondsToYou: return "achievement.diamondsToYou";
+
+ // V1.8 stats
+ case Statistic::AnimalsBred: return "stat.animalsBred";
+ case Statistic::BoatOneCm: return "stat.boatOneCm";
+ case Statistic::ClimbOneCm: return "stat.climbOneCm";
+ case Statistic::CrouchOneCm: return "stat.crouchOneCm";
+ case Statistic::DamageDealt: return "stat.damageDealt";
+ case Statistic::DamageTaken: return "stat.damageTaken";
+ case Statistic::Deaths: return "stat.deaths";
+ case Statistic::Drop: return "stat.drop";
+ case Statistic::FallOneCm: return "stat.fallOneCm";
+ case Statistic::FishCaught: return "stat.fishCaught";
+ case Statistic::FlyOneCm: return "stat.flyOneCm";
+ case Statistic::HorseOneCm: return "stat.horseOneCm";
+ case Statistic::Jump: return "stat.jump";
+ case Statistic::LeaveGame: return "stat.leaveGame";
+ case Statistic::MinecartOneCm: return "stat.minecartOneCm";
+ case Statistic::MobKills: return "stat.mobKills";
+ case Statistic::PigOneCm: return "stat.pigOneCm";
+ case Statistic::PlayerKills: return "stat.playerKills";
+ case Statistic::PlayOneMinute: return "stat.playOneMinute";
+ case Statistic::SprintOneCm: return "stat.sprintOneCm";
+ case Statistic::SwimOneCm: return "stat.swimOneCm";
+ case Statistic::TalkedToVillager: return "stat.talkedToVillager";
+ case Statistic::TimeSinceDeath: return "stat.timeSinceDeath";
+ case Statistic::TradedWithVillager: return "stat.tradedWithVillager";
+ case Statistic::WalkOneCm: return "stat.walkOneCm";
+ case Statistic::WalkUnderWaterOneCm: return "stat.diveOneCm";
+
+ // V1.8.2 stats
+ case Statistic::CleanArmor: return "stat.armorCleaned";
+ case Statistic::CleanBanner: return "stat.bannerCleaned";
+ case Statistic::EatCakeSlice: return "stat.cakeSlicesEaten";
+ case Statistic::EnchantItem: return "stat.itemEnchanted";
+ case Statistic::FillCauldron: return "stat.cauldronFilled";
+ case Statistic::InspectDispenser: return "stat.dispenserInspected";
+ case Statistic::InspectDropper: return "stat.dropperInspected";
+ case Statistic::InspectHopper: return "stat.hopperInspected";
+ case Statistic::InteractWithBeacon: return "stat.beaconInteraction";
+ case Statistic::InteractWithBrewingstand: return "stat.brewingstandInteraction";
+ case Statistic::InteractWithCraftingTable: return "stat.craftingTableInteraction";
+ case Statistic::InteractWithFurnace: return "stat.furnaceInteraction";
+ case Statistic::OpenChest: return "stat.chestOpened";
+ case Statistic::OpenEnderchest: return "stat.enderchestOpened";
+ case Statistic::PlayNoteblock: return "stat.noteblockPlayed";
+ case Statistic::PlayRecord: return "stat.recordPlayed";
+ case Statistic::PotFlower: return "stat.flowerPotted";
+ case Statistic::TriggerTrappedChest: return "stat.trappedChestTriggered";
+ case Statistic::TuneNoteblock: return "stat.noteblockTuned";
+ case Statistic::UseCauldron: return "stat.cauldronUsed";
+
+ // V1.9 stats
+ case Statistic::AviateOneCm: return "stat.aviateOneCm";
+ case Statistic::SleepInBed: return "stat.sleepInBed";
+ case Statistic::SneakTime: return "stat.sneakTime";
+ default: return "";
+ }
+}
diff --git a/src/Protocol/Protocol_1_8.h b/src/Protocol/Protocol_1_8.h
index aec9e2e57..b813b16bf 100644
--- a/src/Protocol/Protocol_1_8.h
+++ b/src/Protocol/Protocol_1_8.h
@@ -15,6 +15,7 @@ Declares the 1.8 protocol classes:
#include "Protocol.h"
#include "../ByteBuffer.h"
+#include "../Registries/Statistics.h"
#include "../mbedTLS++/AesCfb128Decryptor.h"
#include "../mbedTLS++/AesCfb128Encryptor.h"
@@ -254,5 +255,10 @@ private:
/** Converts an entity to a protocol-specific entity type.
Only entities that the Send Spawn Entity packet supports are valid inputs to this method */
- UInt8 GetProtocolEntityType(const cEntity & a_Entity);
+ static UInt8 GetProtocolEntityType(const cEntity & a_Entity);
+
+ /** Converts a statistic to a protocol-specific string.
+ Protocols <= 1.12 use strings, hence this is a static as the string-mapping was append-only for the versions that used it.
+ Returns an empty string, handled correctly by the client, for newer, unsupported statistics. */
+ static const char * GetProtocolStatisticName(Statistic a_Statistic);
} ;
diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp
index 5c5227b5f..533b15e1a 100644
--- a/src/Protocol/Protocol_1_9.cpp
+++ b/src/Protocol/Protocol_1_9.cpp
@@ -24,7 +24,6 @@ Implements the 1.9 protocol classes:
#include "../World.h"
#include "../StringCompression.h"
#include "../CompositeChat.h"
-#include "../Statistics.h"
#include "../JsonUtils.h"
#include "../WorldStorage/FastNBT.h"