diff options
author | nshah25 <68348722+nshah25@users.noreply.github.com> | 2021-05-03 22:07:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-03 22:07:09 +0200 |
commit | 8be1dd54bb17b3ba3e20960aa3c3f696d09facf7 (patch) | |
tree | 334cf9a2c9f781816f8278c933d66a71bf5c7d88 /src/Protocol | |
parent | Style: specify include relativity (#5217) (diff) | |
download | cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.tar cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.tar.gz cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.tar.bz2 cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.tar.lz cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.tar.xz cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.tar.zst cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.zip |
Diffstat (limited to 'src/Protocol')
-rw-r--r-- | src/Protocol/Palettes/Palette_1_13.cpp | 106 | ||||
-rw-r--r-- | src/Protocol/Palettes/Palette_1_13.h | 2 | ||||
-rw-r--r-- | src/Protocol/Palettes/Palette_1_13_1.cpp | 118 | ||||
-rw-r--r-- | src/Protocol/Palettes/Palette_1_13_1.h | 2 | ||||
-rw-r--r-- | src/Protocol/Palettes/Palette_1_14.cpp | 140 | ||||
-rw-r--r-- | src/Protocol/Palettes/Palette_1_14.h | 2 | ||||
-rw-r--r-- | src/Protocol/Palettes/Palette_1_15.cpp | 144 | ||||
-rw-r--r-- | src/Protocol/Palettes/Palette_1_15.h | 2 | ||||
-rw-r--r-- | src/Protocol/Palettes/Palette_1_16.cpp | 150 | ||||
-rw-r--r-- | src/Protocol/Palettes/Palette_1_16.h | 2 | ||||
-rw-r--r-- | src/Protocol/Protocol.h | 5 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_13.cpp | 47 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_13.h | 6 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_14.cpp | 2 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_14.h | 2 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_8.cpp | 199 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_8.h | 4 |
17 files changed, 459 insertions, 474 deletions
diff --git a/src/Protocol/Palettes/Palette_1_13.cpp b/src/Protocol/Palettes/Palette_1_13.cpp index 513763b2a..d60c7a516 100644 --- a/src/Protocol/Palettes/Palette_1_13.cpp +++ b/src/Protocol/Palettes/Palette_1_13.cpp @@ -7859,62 +7859,62 @@ namespace Palette_1_13 } } - UInt32 From(const Statistic ID) + UInt32 From(const CustomStatistic 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; + case CustomStatistic::AnimalsBred: return 25; + case CustomStatistic::AviateOneCm: return 17; + case CustomStatistic::BoatOneCm: return 14; + case CustomStatistic::CleanArmor: return 33; + case CustomStatistic::CleanBanner: return 34; + case CustomStatistic::ClimbOneCm: return 10; + case CustomStatistic::CrouchOneCm: return 6; + case CustomStatistic::DamageDealt: return 21; + case CustomStatistic::DamageTaken: return 22; + case CustomStatistic::Deaths: return 23; + case CustomStatistic::Drop: return 20; + case CustomStatistic::EatCakeSlice: return 30; + case CustomStatistic::EnchantItem: return 45; + case CustomStatistic::FallOneCm: return 9; + case CustomStatistic::FillCauldron: return 31; + case CustomStatistic::FishCaught: return 27; + case CustomStatistic::FlyOneCm: return 11; + case CustomStatistic::HorseOneCm: return 16; + case CustomStatistic::InspectDispenser: return 39; + case CustomStatistic::InspectDropper: return 37; + case CustomStatistic::InspectHopper: return 38; + case CustomStatistic::InteractWithBeacon: return 36; + case CustomStatistic::InteractWithBrewingstand: return 35; + case CustomStatistic::InteractWithCraftingTable: return 48; + case CustomStatistic::InteractWithFurnace: return 47; + case CustomStatistic::Jump: return 19; + case CustomStatistic::LeaveGame: return 0; + case CustomStatistic::MinecartOneCm: return 13; + case CustomStatistic::MobKills: return 24; + case CustomStatistic::OpenChest: return 49; + case CustomStatistic::OpenEnderchest: return 44; + case CustomStatistic::OpenShulkerBox: return 51; + case CustomStatistic::PigOneCm: return 15; + case CustomStatistic::PlayerKills: return 26; + case CustomStatistic::PlayNoteblock: return 40; + case CustomStatistic::PlayOneMinute: return 1; + case CustomStatistic::PlayRecord: return 46; + case CustomStatistic::PotFlower: return 42; + case CustomStatistic::SleepInBed: return 50; + case CustomStatistic::SneakTime: return 4; + case CustomStatistic::SprintOneCm: return 7; + case CustomStatistic::SwimOneCm: return 8; + case CustomStatistic::TalkedToVillager: return 28; + case CustomStatistic::TimeSinceDeath: return 2; + case CustomStatistic::TimeSinceRest: return 3; + case CustomStatistic::TradedWithVillager: return 29; + case CustomStatistic::TriggerTrappedChest: return 43; + case CustomStatistic::TuneNoteblock: return 41; + case CustomStatistic::UseCauldron: return 32; + case CustomStatistic::WalkOneCm: return 5; + case CustomStatistic::WalkOnWaterOneCm: return 18; + case CustomStatistic::WalkUnderWaterOneCm: return 12; default: return UInt32(-1); } } diff --git a/src/Protocol/Palettes/Palette_1_13.h b/src/Protocol/Palettes/Palette_1_13.h index 6f8ceec2e..5b2a5ccb5 100644 --- a/src/Protocol/Palettes/Palette_1_13.h +++ b/src/Protocol/Palettes/Palette_1_13.h @@ -8,6 +8,6 @@ namespace Palette_1_13 { UInt32 From(BlockState Block); UInt32 From(Item ID); - UInt32 From(Statistic ID); + UInt32 From(CustomStatistic 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 cfc4ed5f4..1dba4caf8 100644 --- a/src/Protocol/Palettes/Palette_1_13_1.cpp +++ b/src/Protocol/Palettes/Palette_1_13_1.cpp @@ -7870,68 +7870,68 @@ namespace Palette_1_13_1 } } - UInt32 From(const Statistic ID) + UInt32 From(const CustomStatistic 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; + case CustomStatistic::AnimalsBred: return 30; + case CustomStatistic::AviateOneCm: return 17; + case CustomStatistic::BoatOneCm: return 14; + case CustomStatistic::CleanArmor: return 38; + case CustomStatistic::CleanBanner: return 39; + case CustomStatistic::CleanShulkerBox: return 40; + case CustomStatistic::ClimbOneCm: return 10; + case CustomStatistic::CrouchOneCm: return 6; + case CustomStatistic::DamageAbsorbed: return 26; + case CustomStatistic::DamageBlockedByShield: return 25; + case CustomStatistic::DamageDealt: return 21; + case CustomStatistic::DamageDealtAbsorbed: return 22; + case CustomStatistic::DamageDealtResisted: return 23; + case CustomStatistic::DamageResisted: return 27; + case CustomStatistic::DamageTaken: return 24; + case CustomStatistic::Deaths: return 28; + case CustomStatistic::Drop: return 20; + case CustomStatistic::EatCakeSlice: return 35; + case CustomStatistic::EnchantItem: return 51; + case CustomStatistic::FallOneCm: return 9; + case CustomStatistic::FillCauldron: return 36; + case CustomStatistic::FishCaught: return 32; + case CustomStatistic::FlyOneCm: return 11; + case CustomStatistic::HorseOneCm: return 16; + case CustomStatistic::InspectDispenser: return 45; + case CustomStatistic::InspectDropper: return 43; + case CustomStatistic::InspectHopper: return 44; + case CustomStatistic::InteractWithBeacon: return 42; + case CustomStatistic::InteractWithBrewingstand: return 41; + case CustomStatistic::InteractWithCraftingTable: return 54; + case CustomStatistic::InteractWithFurnace: return 53; + case CustomStatistic::Jump: return 19; + case CustomStatistic::LeaveGame: return 0; + case CustomStatistic::MinecartOneCm: return 13; + case CustomStatistic::MobKills: return 29; + case CustomStatistic::OpenChest: return 55; + case CustomStatistic::OpenEnderchest: return 50; + case CustomStatistic::OpenShulkerBox: return 57; + case CustomStatistic::PigOneCm: return 15; + case CustomStatistic::PlayerKills: return 31; + case CustomStatistic::PlayNoteblock: return 46; + case CustomStatistic::PlayOneMinute: return 1; + case CustomStatistic::PlayRecord: return 52; + case CustomStatistic::PotFlower: return 48; + case CustomStatistic::SleepInBed: return 56; + case CustomStatistic::SneakTime: return 4; + case CustomStatistic::SprintOneCm: return 7; + case CustomStatistic::SwimOneCm: return 8; + case CustomStatistic::TalkedToVillager: return 33; + case CustomStatistic::TimeSinceDeath: return 2; + case CustomStatistic::TimeSinceRest: return 3; + case CustomStatistic::TradedWithVillager: return 34; + case CustomStatistic::TriggerTrappedChest: return 49; + case CustomStatistic::TuneNoteblock: return 47; + case CustomStatistic::UseCauldron: return 37; + case CustomStatistic::WalkOneCm: return 5; + case CustomStatistic::WalkOnWaterOneCm: return 18; + case CustomStatistic::WalkUnderWaterOneCm: return 12; default: return UInt32(-1); } } diff --git a/src/Protocol/Palettes/Palette_1_13_1.h b/src/Protocol/Palettes/Palette_1_13_1.h index 02085aa2b..fda47e5c4 100644 --- a/src/Protocol/Palettes/Palette_1_13_1.h +++ b/src/Protocol/Palettes/Palette_1_13_1.h @@ -8,6 +8,6 @@ namespace Palette_1_13_1 { UInt32 From(BlockState Block); UInt32 From(Item ID); - UInt32 From(Statistic ID); + UInt32 From(CustomStatistic ID); Item ToItem(UInt32 ID); } diff --git a/src/Protocol/Palettes/Palette_1_14.cpp b/src/Protocol/Palettes/Palette_1_14.cpp index 02c871331..0dca7c142 100644 --- a/src/Protocol/Palettes/Palette_1_14.cpp +++ b/src/Protocol/Palettes/Palette_1_14.cpp @@ -9505,79 +9505,79 @@ namespace Palette_1_14 } } - UInt32 From(const Statistic ID) + UInt32 From(const CustomStatistic 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; + case CustomStatistic::AnimalsBred: return 30; + case CustomStatistic::AviateOneCm: return 17; + case CustomStatistic::BellRing: return 66; + case CustomStatistic::BoatOneCm: return 14; + case CustomStatistic::CleanArmor: return 38; + case CustomStatistic::CleanBanner: return 39; + case CustomStatistic::CleanShulkerBox: return 40; + case CustomStatistic::ClimbOneCm: return 10; + case CustomStatistic::CrouchOneCm: return 6; + case CustomStatistic::DamageAbsorbed: return 26; + case CustomStatistic::DamageBlockedByShield: return 25; + case CustomStatistic::DamageDealt: return 21; + case CustomStatistic::DamageDealtAbsorbed: return 22; + case CustomStatistic::DamageDealtResisted: return 23; + case CustomStatistic::DamageResisted: return 27; + case CustomStatistic::DamageTaken: return 24; + case CustomStatistic::Deaths: return 28; + case CustomStatistic::Drop: return 20; + case CustomStatistic::EatCakeSlice: return 35; + case CustomStatistic::EnchantItem: return 51; + case CustomStatistic::FallOneCm: return 9; + case CustomStatistic::FillCauldron: return 36; + case CustomStatistic::FishCaught: return 32; + case CustomStatistic::FlyOneCm: return 11; + case CustomStatistic::HorseOneCm: return 16; + case CustomStatistic::InspectDispenser: return 45; + case CustomStatistic::InspectDropper: return 43; + case CustomStatistic::InspectHopper: return 44; + case CustomStatistic::InteractWithBeacon: return 42; + case CustomStatistic::InteractWithBlastFurnace: return 59; + case CustomStatistic::InteractWithBrewingstand: return 41; + case CustomStatistic::InteractWithCampfire: return 62; + case CustomStatistic::InteractWithCartographyTable: return 63; + case CustomStatistic::InteractWithCraftingTable: return 54; + case CustomStatistic::InteractWithFurnace: return 53; + case CustomStatistic::InteractWithLectern: return 61; + case CustomStatistic::InteractWithLoom: return 64; + case CustomStatistic::InteractWithSmoker: return 60; + case CustomStatistic::InteractWithStonecutter: return 65; + case CustomStatistic::Jump: return 19; + case CustomStatistic::LeaveGame: return 0; + case CustomStatistic::MinecartOneCm: return 13; + case CustomStatistic::MobKills: return 29; + case CustomStatistic::OpenBarrel: return 58; + case CustomStatistic::OpenChest: return 55; + case CustomStatistic::OpenEnderchest: return 50; + case CustomStatistic::OpenShulkerBox: return 57; + case CustomStatistic::PigOneCm: return 15; + case CustomStatistic::PlayerKills: return 31; + case CustomStatistic::PlayNoteblock: return 46; + case CustomStatistic::PlayOneMinute: return 1; + case CustomStatistic::PlayRecord: return 52; + case CustomStatistic::PotFlower: return 48; + case CustomStatistic::RaidTrigger: return 67; + case CustomStatistic::RaidWin: return 68; + case CustomStatistic::SleepInBed: return 56; + case CustomStatistic::SneakTime: return 4; + case CustomStatistic::SprintOneCm: return 7; + case CustomStatistic::SwimOneCm: return 18; + case CustomStatistic::TalkedToVillager: return 33; + case CustomStatistic::TimeSinceDeath: return 2; + case CustomStatistic::TimeSinceRest: return 3; + case CustomStatistic::TradedWithVillager: return 34; + case CustomStatistic::TriggerTrappedChest: return 49; + case CustomStatistic::TuneNoteblock: return 47; + case CustomStatistic::UseCauldron: return 37; + case CustomStatistic::WalkOneCm: return 5; + case CustomStatistic::WalkOnWaterOneCm: return 8; + case CustomStatistic::WalkUnderWaterOneCm: return 12; default: return static_cast<UInt32>(-1); } } diff --git a/src/Protocol/Palettes/Palette_1_14.h b/src/Protocol/Palettes/Palette_1_14.h index 037d9b4c1..c92a19eba 100644 --- a/src/Protocol/Palettes/Palette_1_14.h +++ b/src/Protocol/Palettes/Palette_1_14.h @@ -8,6 +8,6 @@ namespace Palette_1_14 { UInt32 From(BlockState Block); UInt32 From(Item ID); - UInt32 From(Statistic ID); + UInt32 From(CustomStatistic ID); Item ToItem(UInt32 ID); } diff --git a/src/Protocol/Palettes/Palette_1_15.cpp b/src/Protocol/Palettes/Palette_1_15.cpp index 4070a3715..29467d6d7 100644 --- a/src/Protocol/Palettes/Palette_1_15.cpp +++ b/src/Protocol/Palettes/Palette_1_15.cpp @@ -9578,81 +9578,81 @@ namespace Palette_1_15 } } - UInt32 From(const Statistic ID) + UInt32 From(const CustomStatistic 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::InteractWithAnvil: return 69; - 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::InteractWithGrindstone: return 70; - 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::PlayNoteblock: return 46; - case Statistic::PlayOneMinute: return 1; - case Statistic::PlayRecord: return 52; - case Statistic::PlayerKills: return 31; - 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::WalkOnWaterOneCm: return 8; - case Statistic::WalkOneCm: return 5; - case Statistic::WalkUnderWaterOneCm: return 12; + case CustomStatistic::AnimalsBred: return 30; + case CustomStatistic::AviateOneCm: return 17; + case CustomStatistic::BellRing: return 66; + case CustomStatistic::BoatOneCm: return 14; + case CustomStatistic::CleanArmor: return 38; + case CustomStatistic::CleanBanner: return 39; + case CustomStatistic::CleanShulkerBox: return 40; + case CustomStatistic::ClimbOneCm: return 10; + case CustomStatistic::CrouchOneCm: return 6; + case CustomStatistic::DamageAbsorbed: return 26; + case CustomStatistic::DamageBlockedByShield: return 25; + case CustomStatistic::DamageDealt: return 21; + case CustomStatistic::DamageDealtAbsorbed: return 22; + case CustomStatistic::DamageDealtResisted: return 23; + case CustomStatistic::DamageResisted: return 27; + case CustomStatistic::DamageTaken: return 24; + case CustomStatistic::Deaths: return 28; + case CustomStatistic::Drop: return 20; + case CustomStatistic::EatCakeSlice: return 35; + case CustomStatistic::EnchantItem: return 51; + case CustomStatistic::FallOneCm: return 9; + case CustomStatistic::FillCauldron: return 36; + case CustomStatistic::FishCaught: return 32; + case CustomStatistic::FlyOneCm: return 11; + case CustomStatistic::HorseOneCm: return 16; + case CustomStatistic::InspectDispenser: return 45; + case CustomStatistic::InspectDropper: return 43; + case CustomStatistic::InspectHopper: return 44; + case CustomStatistic::InteractWithAnvil: return 69; + case CustomStatistic::InteractWithBeacon: return 42; + case CustomStatistic::InteractWithBlastFurnace: return 59; + case CustomStatistic::InteractWithBrewingstand: return 41; + case CustomStatistic::InteractWithCampfire: return 62; + case CustomStatistic::InteractWithCartographyTable: return 63; + case CustomStatistic::InteractWithCraftingTable: return 54; + case CustomStatistic::InteractWithFurnace: return 53; + case CustomStatistic::InteractWithGrindstone: return 70; + case CustomStatistic::InteractWithLectern: return 61; + case CustomStatistic::InteractWithLoom: return 64; + case CustomStatistic::InteractWithSmoker: return 60; + case CustomStatistic::InteractWithStonecutter: return 65; + case CustomStatistic::Jump: return 19; + case CustomStatistic::LeaveGame: return -0; + case CustomStatistic::MinecartOneCm: return 13; + case CustomStatistic::MobKills: return 29; + case CustomStatistic::OpenBarrel: return 58; + case CustomStatistic::OpenChest: return 55; + case CustomStatistic::OpenEnderchest: return 50; + case CustomStatistic::OpenShulkerBox: return 57; + case CustomStatistic::PigOneCm: return 15; + case CustomStatistic::PlayNoteblock: return 46; + case CustomStatistic::PlayOneMinute: return 1; + case CustomStatistic::PlayRecord: return 52; + case CustomStatistic::PlayerKills: return 31; + case CustomStatistic::PotFlower: return 48; + case CustomStatistic::RaidTrigger: return 67; + case CustomStatistic::RaidWin: return 68; + case CustomStatistic::SleepInBed: return 56; + case CustomStatistic::SneakTime: return 4; + case CustomStatistic::SprintOneCm: return 7; + case CustomStatistic::SwimOneCm: return 18; + case CustomStatistic::TalkedToVillager: return 33; + case CustomStatistic::TimeSinceDeath: return 2; + case CustomStatistic::TimeSinceRest: return 3; + case CustomStatistic::TradedWithVillager: return 34; + case CustomStatistic::TriggerTrappedChest: return 49; + case CustomStatistic::TuneNoteblock: return 47; + case CustomStatistic::UseCauldron: return 37; + case CustomStatistic::WalkOnWaterOneCm: return 8; + case CustomStatistic::WalkOneCm: return 5; + case CustomStatistic::WalkUnderWaterOneCm: return 12; default: return UInt32(-1); } } diff --git a/src/Protocol/Palettes/Palette_1_15.h b/src/Protocol/Palettes/Palette_1_15.h index 7fcac7e72..22c993de7 100644 --- a/src/Protocol/Palettes/Palette_1_15.h +++ b/src/Protocol/Palettes/Palette_1_15.h @@ -8,6 +8,6 @@ namespace Palette_1_15 { UInt32 From(BlockState Block); UInt32 From(Item ID); - UInt32 From(Statistic ID); + UInt32 From(CustomStatistic ID); Item ToItem(UInt32 ID); } diff --git a/src/Protocol/Palettes/Palette_1_16.cpp b/src/Protocol/Palettes/Palette_1_16.cpp index fae43766d..86b684cb8 100644 --- a/src/Protocol/Palettes/Palette_1_16.cpp +++ b/src/Protocol/Palettes/Palette_1_16.cpp @@ -12762,84 +12762,84 @@ namespace Palette_1_16 UNREACHABLE("Invalid item"); } - UInt32 From(const Statistic ID) + UInt32 From(const CustomStatistic ID) { switch (ID) { - case Statistic::AnimalsBred: return 31; - case Statistic::AviateOneCm: return 17; - case Statistic::BellRing: return 67; - case Statistic::BoatOneCm: return 14; - case Statistic::CleanArmor: return 39; - case Statistic::CleanBanner: return 40; - case Statistic::CleanShulkerBox: return 41; - case Statistic::ClimbOneCm: return 10; - case Statistic::CrouchOneCm: return 6; - case Statistic::DamageAbsorbed: return 27; - case Statistic::DamageBlockedByShield: return 26; - case Statistic::DamageDealt: return 22; - case Statistic::DamageDealtAbsorbed: return 23; - case Statistic::DamageDealtResisted: return 24; - case Statistic::DamageResisted: return 28; - case Statistic::DamageTaken: return 25; - case Statistic::Deaths: return 29; - case Statistic::Drop: return 21; - case Statistic::EatCakeSlice: return 36; - case Statistic::EnchantItem: return 52; - case Statistic::FallOneCm: return 9; - case Statistic::FillCauldron: return 37; - case Statistic::FishCaught: return 33; - case Statistic::FlyOneCm: return 11; - case Statistic::HorseOneCm: return 16; - case Statistic::InspectDispenser: return 46; - case Statistic::InspectDropper: return 44; - case Statistic::InspectHopper: return 45; - case Statistic::InteractWithAnvil: return 70; - case Statistic::InteractWithBeacon: return 43; - case Statistic::InteractWithBlastFurnace: return 60; - case Statistic::InteractWithBrewingstand: return 42; - case Statistic::InteractWithCampfire: return 63; - case Statistic::InteractWithCartographyTable: return 64; - case Statistic::InteractWithCraftingTable: return 55; - case Statistic::InteractWithFurnace: return 54; - case Statistic::InteractWithGrindstone: return 71; - case Statistic::InteractWithLectern: return 62; - case Statistic::InteractWithLoom: return 65; - case Statistic::InteractWithSmithingTable: return 73; - case Statistic::InteractWithSmoker: return 61; - case Statistic::InteractWithStonecutter: return 66; - case Statistic::Jump: return 20; - case Statistic::LeaveGame: return -0; - case Statistic::MinecartOneCm: return 13; - case Statistic::MobKills: return 30; - case Statistic::OpenBarrel: return 59; - case Statistic::OpenChest: return 56; - case Statistic::OpenEnderchest: return 51; - case Statistic::OpenShulkerBox: return 58; - case Statistic::PigOneCm: return 15; - case Statistic::PlayNoteblock: return 47; - case Statistic::PlayOneMinute: return 1; - case Statistic::PlayRecord: return 53; - case Statistic::PlayerKills: return 32; - case Statistic::PotFlower: return 49; - case Statistic::RaidTrigger: return 68; - case Statistic::RaidWin: return 69; - case Statistic::SleepInBed: return 57; - case Statistic::SneakTime: return 4; - case Statistic::SprintOneCm: return 7; - case Statistic::StriderOneCm: return 19; - case Statistic::SwimOneCm: return 18; - case Statistic::TalkedToVillager: return 34; - case Statistic::TargetHit: return 72; - case Statistic::TimeSinceDeath: return 2; - case Statistic::TimeSinceRest: return 3; - case Statistic::TradedWithVillager: return 35; - case Statistic::TriggerTrappedChest: return 50; - case Statistic::TuneNoteblock: return 48; - case Statistic::UseCauldron: return 38; - case Statistic::WalkOnWaterOneCm: return 8; - case Statistic::WalkOneCm: return 5; - case Statistic::WalkUnderWaterOneCm: return 12; + case CustomStatistic::AnimalsBred: return 31; + case CustomStatistic::AviateOneCm: return 17; + case CustomStatistic::BellRing: return 67; + case CustomStatistic::BoatOneCm: return 14; + case CustomStatistic::CleanArmor: return 39; + case CustomStatistic::CleanBanner: return 40; + case CustomStatistic::CleanShulkerBox: return 41; + case CustomStatistic::ClimbOneCm: return 10; + case CustomStatistic::CrouchOneCm: return 6; + case CustomStatistic::DamageAbsorbed: return 27; + case CustomStatistic::DamageBlockedByShield: return 26; + case CustomStatistic::DamageDealt: return 22; + case CustomStatistic::DamageDealtAbsorbed: return 23; + case CustomStatistic::DamageDealtResisted: return 24; + case CustomStatistic::DamageResisted: return 28; + case CustomStatistic::DamageTaken: return 25; + case CustomStatistic::Deaths: return 29; + case CustomStatistic::Drop: return 21; + case CustomStatistic::EatCakeSlice: return 36; + case CustomStatistic::EnchantItem: return 52; + case CustomStatistic::FallOneCm: return 9; + case CustomStatistic::FillCauldron: return 37; + case CustomStatistic::FishCaught: return 33; + case CustomStatistic::FlyOneCm: return 11; + case CustomStatistic::HorseOneCm: return 16; + case CustomStatistic::InspectDispenser: return 46; + case CustomStatistic::InspectDropper: return 44; + case CustomStatistic::InspectHopper: return 45; + case CustomStatistic::InteractWithAnvil: return 70; + case CustomStatistic::InteractWithBeacon: return 43; + case CustomStatistic::InteractWithBlastFurnace: return 60; + case CustomStatistic::InteractWithBrewingstand: return 42; + case CustomStatistic::InteractWithCampfire: return 63; + case CustomStatistic::InteractWithCartographyTable: return 64; + case CustomStatistic::InteractWithCraftingTable: return 55; + case CustomStatistic::InteractWithFurnace: return 54; + case CustomStatistic::InteractWithGrindstone: return 71; + case CustomStatistic::InteractWithLectern: return 62; + case CustomStatistic::InteractWithLoom: return 65; + case CustomStatistic::InteractWithSmithingTable: return 73; + case CustomStatistic::InteractWithSmoker: return 61; + case CustomStatistic::InteractWithStonecutter: return 66; + case CustomStatistic::Jump: return 20; + case CustomStatistic::LeaveGame: return -0; + case CustomStatistic::MinecartOneCm: return 13; + case CustomStatistic::MobKills: return 30; + case CustomStatistic::OpenBarrel: return 59; + case CustomStatistic::OpenChest: return 56; + case CustomStatistic::OpenEnderchest: return 51; + case CustomStatistic::OpenShulkerBox: return 58; + case CustomStatistic::PigOneCm: return 15; + case CustomStatistic::PlayNoteblock: return 47; + case CustomStatistic::PlayOneMinute: return 1; + case CustomStatistic::PlayRecord: return 53; + case CustomStatistic::PlayerKills: return 32; + case CustomStatistic::PotFlower: return 49; + case CustomStatistic::RaidTrigger: return 68; + case CustomStatistic::RaidWin: return 69; + case CustomStatistic::SleepInBed: return 57; + case CustomStatistic::SneakTime: return 4; + case CustomStatistic::SprintOneCm: return 7; + case CustomStatistic::StriderOneCm: return 19; + case CustomStatistic::SwimOneCm: return 18; + case CustomStatistic::TalkedToVillager: return 34; + case CustomStatistic::TargetHit: return 72; + case CustomStatistic::TimeSinceDeath: return 2; + case CustomStatistic::TimeSinceRest: return 3; + case CustomStatistic::TradedWithVillager: return 35; + case CustomStatistic::TriggerTrappedChest: return 50; + case CustomStatistic::TuneNoteblock: return 48; + case CustomStatistic::UseCauldron: return 38; + case CustomStatistic::WalkOnWaterOneCm: return 8; + case CustomStatistic::WalkOneCm: return 5; + case CustomStatistic::WalkUnderWaterOneCm: return 12; default: return UInt32(-1); } } diff --git a/src/Protocol/Palettes/Palette_1_16.h b/src/Protocol/Palettes/Palette_1_16.h index 6e6e632ce..ae6cf9484 100644 --- a/src/Protocol/Palettes/Palette_1_16.h +++ b/src/Protocol/Palettes/Palette_1_16.h @@ -8,6 +8,6 @@ namespace Palette_1_16 { UInt32 From(BlockState Block); UInt32 From(Item ID); - UInt32 From(Statistic ID); + UInt32 From(CustomStatistic ID); Item ToItem(UInt32 ID); } diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index c87ab4a7d..334d8d56b 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -29,9 +29,10 @@ class cPainting; class cWorld; class cMonster; class cCompositeChat; -class cStatManager; class cPacketizer; +struct StatisticsManager; + @@ -422,7 +423,7 @@ public: virtual void SendSoundParticleEffect (const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) = 0; virtual void SendSpawnEntity (const cEntity & a_Entity) = 0; virtual void SendSpawnMob (const cMonster & a_Mob) = 0; - virtual void SendStatistics (const cStatManager & a_Manager) = 0; + virtual void SendStatistics (const StatisticsManager & a_Manager) = 0; virtual void SendTabCompletionResults (const AStringVector & a_Results) = 0; virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) = 0; virtual void SendTitleTimes (int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks) = 0; diff --git a/src/Protocol/Protocol_1_13.cpp b/src/Protocol/Protocol_1_13.cpp index 44a011c76..336f3c339 100644 --- a/src/Protocol/Protocol_1_13.cpp +++ b/src/Protocol/Protocol_1_13.cpp @@ -142,24 +142,22 @@ void cProtocol_1_13::SendScoreboardObjective(const AString & a_Name, const AStri -void cProtocol_1_13::SendStatistics(const cStatManager & a_Manager) +void cProtocol_1_13::SendStatistics(const StatisticsManager & a_Manager) { ASSERT(m_State == 3); // In game mode? UInt32 Size = 0; - a_Manager.ForEachStatisticType([this, &Size](const auto & Store) + + for (const auto & [Statistic, Value] : a_Manager.Custom) { - 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 + // 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++; - } + if (GetProtocolStatisticType(Statistic) != 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 @@ -167,22 +165,19 @@ void cProtocol_1_13::SendStatistics(const cStatManager & a_Manager) cPacketizer Pkt(*this, pktStatistics); Pkt.WriteVarInt32(Size); - a_Manager.ForEachStatisticType([this, &Pkt](const cStatManager::CustomStore & Store) + for (const auto & [Statistic, Value] : a_Manager.Custom) { - for (const auto & Item : Store) + const auto ID = GetProtocolStatisticType(Statistic); + if (ID == static_cast<UInt32>(-1)) { - 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)); + // Unsupported, don't send: + continue; } - }); + + Pkt.WriteVarInt32(8); // "Custom" category. + Pkt.WriteVarInt32(ID); + Pkt.WriteVarInt32(static_cast<UInt32>(Value)); + } } @@ -588,7 +583,7 @@ UInt32 cProtocol_1_13::GetProtocolMobType(eMonsterType a_MobType) const -UInt32 cProtocol_1_13::GetProtocolStatisticType(Statistic a_Statistic) const +UInt32 cProtocol_1_13::GetProtocolStatisticType(const CustomStatistic a_Statistic) const { return Palette_1_13::From(a_Statistic); } @@ -1480,7 +1475,7 @@ UInt32 cProtocol_1_13_1::GetProtocolItemType(short a_ItemID, short a_ItemDamage) -UInt32 cProtocol_1_13_1::GetProtocolStatisticType(Statistic a_Statistic) const +UInt32 cProtocol_1_13_1::GetProtocolStatisticType(const CustomStatistic a_Statistic) const { return Palette_1_13_1::From(a_Statistic); } diff --git a/src/Protocol/Protocol_1_13.h b/src/Protocol/Protocol_1_13.h index b478fe5ed..53e7cdc91 100644 --- a/src/Protocol/Protocol_1_13.h +++ b/src/Protocol/Protocol_1_13.h @@ -42,7 +42,7 @@ protected: virtual void SendPaintingSpawn (const cPainting & a_Painting) override; virtual void SendParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data) override; virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override; - virtual void SendStatistics (const cStatManager & a_Manager) override; + virtual void SendStatistics (const StatisticsManager & a_Manager) override; virtual void SendTabCompletionResults (const AStringVector & a_Results) override; virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) override; virtual UInt8 GetEntityMetadataID(EntityMetadata a_Metadata) const; @@ -53,7 +53,7 @@ protected: virtual signed char GetProtocolEntityStatus(EntityAnimation a_Animation) const override; virtual UInt32 GetProtocolItemType(short a_ItemID, short a_ItemDamage) const; virtual UInt32 GetProtocolMobType(eMonsterType a_MobType) const override; - virtual UInt32 GetProtocolStatisticType(Statistic a_Statistic) const; + virtual UInt32 GetProtocolStatisticType(CustomStatistic a_Statistic) const; virtual Version GetProtocolVersion() const override; virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) override; @@ -88,7 +88,7 @@ protected: virtual std::pair<short, short> GetItemFromProtocolID(UInt32 a_ProtocolID) const override; virtual UInt32 GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override; virtual UInt32 GetProtocolItemType(short a_ItemID, short a_ItemDamage) const override; - virtual UInt32 GetProtocolStatisticType(Statistic a_Statistic) const override; + virtual UInt32 GetProtocolStatisticType(CustomStatistic a_Statistic) const override; virtual Version GetProtocolVersion() const override; }; diff --git a/src/Protocol/Protocol_1_14.cpp b/src/Protocol/Protocol_1_14.cpp index f2bbdd955..161bf2f4d 100644 --- a/src/Protocol/Protocol_1_14.cpp +++ b/src/Protocol/Protocol_1_14.cpp @@ -238,7 +238,7 @@ UInt32 cProtocol_1_14::GetProtocolItemType(short a_ItemID, short a_ItemDamage) c -UInt32 cProtocol_1_14::GetProtocolStatisticType(Statistic a_Statistic) const +UInt32 cProtocol_1_14::GetProtocolStatisticType(const CustomStatistic a_Statistic) const { return Palette_1_14::From(a_Statistic); } diff --git a/src/Protocol/Protocol_1_14.h b/src/Protocol/Protocol_1_14.h index 32ae6640e..f4907a7d0 100644 --- a/src/Protocol/Protocol_1_14.h +++ b/src/Protocol/Protocol_1_14.h @@ -45,7 +45,7 @@ protected: virtual UInt32 GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override; virtual signed char GetProtocolEntityStatus(EntityAnimation a_Animation) const override; virtual UInt32 GetProtocolItemType(short a_ItemID, short a_ItemDamage) const override; - virtual UInt32 GetProtocolStatisticType(Statistic a_Statistic) const override; + virtual UInt32 GetProtocolStatisticType(CustomStatistic a_Statistic) const override; virtual Version GetProtocolVersion() const override; virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) override; diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp index 78483a45d..980348887 100644 --- a/src/Protocol/Protocol_1_8.cpp +++ b/src/Protocol/Protocol_1_8.cpp @@ -1458,30 +1458,21 @@ void cProtocol_1_8_0::SendSpawnMob(const cMonster & a_Mob) -void cProtocol_1_8_0::SendStatistics(const cStatManager & a_Manager) +void cProtocol_1_8_0::SendStatistics(const StatisticsManager & 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(Size); - a_Manager.ForEachStatisticType([&Pkt](const cStatManager::CustomStore & Store) + // No need to check Size != 0. + // Assume that the vast majority of the time there's at least one statistic to send: + Pkt.WriteVarInt32(static_cast<UInt32>(a_Manager.Custom.size())); + + for (const auto & [Statistic, Value] : a_Manager.Custom) { - for (const auto & Item : Store) - { - Pkt.WriteString(GetProtocolStatisticName(Item.first)); - Pkt.WriteVarInt32(static_cast<UInt32>(Item.second)); - } - }); + Pkt.WriteString(GetProtocolStatisticName(Statistic)); + Pkt.WriteVarInt32(static_cast<UInt32>(Value)); + } } @@ -2401,15 +2392,13 @@ void cProtocol_1_8_0::HandlePacketClientStatus(cByteBuffer & a_ByteBuffer) case 1: { // Request stats - const cStatManager & Manager = m_Client->GetPlayer()->GetStatManager(); - SendStatistics(Manager); - + SendStatistics(m_Client->GetPlayer()->GetStatistics()); break; } case 2: { // Open Inventory achievement - m_Client->GetPlayer()->AwardAchievement(Statistic::AchOpenInventory); + m_Client->GetPlayer()->AwardAchievement(CustomStatistic::AchOpenInventory); break; } } @@ -4042,99 +4031,99 @@ int cProtocol_1_8_0::GetProtocolParticleID(const AString & a_ParticleName) -const char * cProtocol_1_8_0::GetProtocolStatisticName(Statistic a_Statistic) +const char * cProtocol_1_8_0::GetProtocolStatisticName(const CustomStatistic 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"; + case CustomStatistic::AchOpenInventory: return "achievement.openInventory"; + case CustomStatistic::AchMineWood: return "achievement.mineWood"; + case CustomStatistic::AchBuildWorkBench: return "achievement.buildWorkBench"; + case CustomStatistic::AchBuildPickaxe: return "achievement.buildPickaxe"; + case CustomStatistic::AchBuildFurnace: return "achievement.buildFurnace"; + case CustomStatistic::AchAcquireIron: return "achievement.acquireIron"; + case CustomStatistic::AchBuildHoe: return "achievement.buildHoe"; + case CustomStatistic::AchMakeBread: return "achievement.makeBread"; + case CustomStatistic::AchBakeCake: return "achievement.bakeCake"; + case CustomStatistic::AchBuildBetterPickaxe: return "achievement.buildBetterPickaxe"; + case CustomStatistic::AchCookFish: return "achievement.cookFish"; + case CustomStatistic::AchOnARail: return "achievement.onARail"; + case CustomStatistic::AchBuildSword: return "achievement.buildSword"; + case CustomStatistic::AchKillEnemy: return "achievement.killEnemy"; + case CustomStatistic::AchKillCow: return "achievement.killCow"; + case CustomStatistic::AchFlyPig: return "achievement.flyPig"; + case CustomStatistic::AchSnipeSkeleton: return "achievement.snipeSkeleton"; + case CustomStatistic::AchDiamonds: return "achievement.diamonds"; + case CustomStatistic::AchPortal: return "achievement.portal"; + case CustomStatistic::AchGhast: return "achievement.ghast"; + case CustomStatistic::AchBlazeRod: return "achievement.blazeRod"; + case CustomStatistic::AchPotion: return "achievement.potion"; + case CustomStatistic::AchTheEnd: return "achievement.theEnd"; + case CustomStatistic::AchTheEnd2: return "achievement.theEnd2"; + case CustomStatistic::AchEnchantments: return "achievement.enchantments"; + case CustomStatistic::AchOverkill: return "achievement.overkill"; + case CustomStatistic::AchBookcase: return "achievement.bookcase"; + case CustomStatistic::AchExploreAllBiomes: return "achievement.exploreAllBiomes"; + case CustomStatistic::AchSpawnWither: return "achievement.spawnWither"; + case CustomStatistic::AchKillWither: return "achievement.killWither"; + case CustomStatistic::AchFullBeacon: return "achievement.fullBeacon"; + case CustomStatistic::AchBreedCow: return "achievement.breedCow"; + case CustomStatistic::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"; + case CustomStatistic::AnimalsBred: return "stat.animalsBred"; + case CustomStatistic::BoatOneCm: return "stat.boatOneCm"; + case CustomStatistic::ClimbOneCm: return "stat.climbOneCm"; + case CustomStatistic::CrouchOneCm: return "stat.crouchOneCm"; + case CustomStatistic::DamageDealt: return "stat.damageDealt"; + case CustomStatistic::DamageTaken: return "stat.damageTaken"; + case CustomStatistic::Deaths: return "stat.deaths"; + case CustomStatistic::Drop: return "stat.drop"; + case CustomStatistic::FallOneCm: return "stat.fallOneCm"; + case CustomStatistic::FishCaught: return "stat.fishCaught"; + case CustomStatistic::FlyOneCm: return "stat.flyOneCm"; + case CustomStatistic::HorseOneCm: return "stat.horseOneCm"; + case CustomStatistic::Jump: return "stat.jump"; + case CustomStatistic::LeaveGame: return "stat.leaveGame"; + case CustomStatistic::MinecartOneCm: return "stat.minecartOneCm"; + case CustomStatistic::MobKills: return "stat.mobKills"; + case CustomStatistic::PigOneCm: return "stat.pigOneCm"; + case CustomStatistic::PlayerKills: return "stat.playerKills"; + case CustomStatistic::PlayOneMinute: return "stat.playOneMinute"; + case CustomStatistic::SprintOneCm: return "stat.sprintOneCm"; + case CustomStatistic::SwimOneCm: return "stat.swimOneCm"; + case CustomStatistic::TalkedToVillager: return "stat.talkedToVillager"; + case CustomStatistic::TimeSinceDeath: return "stat.timeSinceDeath"; + case CustomStatistic::TradedWithVillager: return "stat.tradedWithVillager"; + case CustomStatistic::WalkOneCm: return "stat.walkOneCm"; + case CustomStatistic::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"; + case CustomStatistic::CleanArmor: return "stat.armorCleaned"; + case CustomStatistic::CleanBanner: return "stat.bannerCleaned"; + case CustomStatistic::EatCakeSlice: return "stat.cakeSlicesEaten"; + case CustomStatistic::EnchantItem: return "stat.itemEnchanted"; + case CustomStatistic::FillCauldron: return "stat.cauldronFilled"; + case CustomStatistic::InspectDispenser: return "stat.dispenserInspected"; + case CustomStatistic::InspectDropper: return "stat.dropperInspected"; + case CustomStatistic::InspectHopper: return "stat.hopperInspected"; + case CustomStatistic::InteractWithBeacon: return "stat.beaconInteraction"; + case CustomStatistic::InteractWithBrewingstand: return "stat.brewingstandInteraction"; + case CustomStatistic::InteractWithCraftingTable: return "stat.craftingTableInteraction"; + case CustomStatistic::InteractWithFurnace: return "stat.furnaceInteraction"; + case CustomStatistic::OpenChest: return "stat.chestOpened"; + case CustomStatistic::OpenEnderchest: return "stat.enderchestOpened"; + case CustomStatistic::PlayNoteblock: return "stat.noteblockPlayed"; + case CustomStatistic::PlayRecord: return "stat.recordPlayed"; + case CustomStatistic::PotFlower: return "stat.flowerPotted"; + case CustomStatistic::TriggerTrappedChest: return "stat.trappedChestTriggered"; + case CustomStatistic::TuneNoteblock: return "stat.noteblockTuned"; + case CustomStatistic::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"; + case CustomStatistic::AviateOneCm: return "stat.aviateOneCm"; + case CustomStatistic::SleepInBed: return "stat.sleepInBed"; + case CustomStatistic::SneakTime: return "stat.sneakTime"; default: return ""; } } diff --git a/src/Protocol/Protocol_1_8.h b/src/Protocol/Protocol_1_8.h index 652ef69c5..faea84e57 100644 --- a/src/Protocol/Protocol_1_8.h +++ b/src/Protocol/Protocol_1_8.h @@ -113,7 +113,7 @@ public: virtual void SendSoundParticleEffect (const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override; virtual void SendSpawnEntity (const cEntity & a_Entity) override; virtual void SendSpawnMob (const cMonster & a_Mob) override; - virtual void SendStatistics (const cStatManager & a_Manager) override; + virtual void SendStatistics (const StatisticsManager & a_Manager) override; virtual void SendTabCompletionResults (const AStringVector & a_Results) override; virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void SendTitleTimes (int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks) override; @@ -267,7 +267,7 @@ private: /** 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); + static const char * GetProtocolStatisticName(CustomStatistic a_Statistic); /** Handle a complete packet stored in the given buffer. */ void HandlePacket(cByteBuffer & a_Buffer); |