From c2f8ceb554982a33bcd4a1e168f6c4e26d0b85dd Mon Sep 17 00:00:00 2001 From: 12xx12 <44411062+12xx12@users.noreply.github.com> Date: Sat, 5 Sep 2020 17:13:44 +0200 Subject: Add more statistic tracking (#4837) + Added possible 1.8 stats + Added stat tracking for 1.8.2 + Added stat tracking for 1.9 + Added the breed cow achievement Co-authored-by: 12xx12 <12xx12100@gmail.com> --- src/BlockEntities/BeaconEntity.cpp | 2 ++ src/BlockEntities/BrewingstandEntity.cpp | 2 ++ src/BlockEntities/ChestEntity.cpp | 9 +++++++++ src/BlockEntities/DropSpenserEntity.cpp | 9 +++++++++ src/BlockEntities/EnderChestEntity.cpp | 3 +++ src/BlockEntities/FlowerPotEntity.cpp | 2 ++ src/BlockEntities/FurnaceEntity.cpp | 2 ++ src/BlockEntities/HopperEntity.cpp | 2 ++ src/BlockEntities/JukeboxEntity.cpp | 2 ++ src/BlockEntities/NoteEntity.cpp | 3 ++- 10 files changed, 35 insertions(+), 1 deletion(-) (limited to 'src/BlockEntities') diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp index 9923be749..f9ceb6f34 100644 --- a/src/BlockEntities/BeaconEntity.cpp +++ b/src/BlockEntities/BeaconEntity.cpp @@ -303,6 +303,8 @@ bool cBeaconEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) bool cBeaconEntity::UsedBy(cPlayer * a_Player) { + a_Player->GetStatManager().AddValue(Statistic::InteractWithBeacon); + cWindow * Window = GetWindow(); if (Window == nullptr) { diff --git a/src/BlockEntities/BrewingstandEntity.cpp b/src/BlockEntities/BrewingstandEntity.cpp index 3f437d4cb..27dabf177 100644 --- a/src/BlockEntities/BrewingstandEntity.cpp +++ b/src/BlockEntities/BrewingstandEntity.cpp @@ -156,6 +156,8 @@ bool cBrewingstandEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) bool cBrewingstandEntity::UsedBy(cPlayer * a_Player) { + a_Player->GetStatManager().AddValue(Statistic::InteractWithBrewingstand); + cWindow * Window = GetWindow(); if (Window == nullptr) { diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp index 0f005fb53..8c8e75b25 100644 --- a/src/BlockEntities/ChestEntity.cpp +++ b/src/BlockEntities/ChestEntity.cpp @@ -105,6 +105,15 @@ bool cChestEntity::UsedBy(cPlayer * a_Player) } } + if (m_BlockType == E_BLOCK_CHEST) + { + a_Player->GetStatManager().AddValue(Statistic::OpenChest); + } + else // E_BLOCK_TRAPPED_CHEST + { + a_Player->GetStatManager().AddValue(Statistic::TriggerTrappedChest); + } + // If the window is not created, open it anew: cWindow * Window = PrimaryChest->GetWindow(); if (Window == nullptr) diff --git a/src/BlockEntities/DropSpenserEntity.cpp b/src/BlockEntities/DropSpenserEntity.cpp index 2b048bce2..97a67ff60 100644 --- a/src/BlockEntities/DropSpenserEntity.cpp +++ b/src/BlockEntities/DropSpenserEntity.cpp @@ -153,6 +153,15 @@ void cDropSpenserEntity::SendTo(cClientHandle & a_Client) bool cDropSpenserEntity::UsedBy(cPlayer * a_Player) { + if (m_BlockType == E_BLOCK_DISPENSER) + { + a_Player->GetStatManager().AddValue(Statistic::InspectDispenser); + } + else // E_BLOCK_DROPPER + { + a_Player->GetStatManager().AddValue(Statistic::InspectDropper); + } + cWindow * Window = GetWindow(); if (Window == nullptr) { diff --git a/src/BlockEntities/EnderChestEntity.cpp b/src/BlockEntities/EnderChestEntity.cpp index 74e6a7d23..44bfaf7d4 100644 --- a/src/BlockEntities/EnderChestEntity.cpp +++ b/src/BlockEntities/EnderChestEntity.cpp @@ -61,6 +61,9 @@ bool cEnderChestEntity::UsedBy(cPlayer * a_Player) // Obstruction, don't open return false; } + + a_Player->GetStatManager().AddValue(Statistic::OpenEnderchest); + // If the window is not created, open it anew: cWindow * Window = GetWindow(); if (Window == nullptr) diff --git a/src/BlockEntities/FlowerPotEntity.cpp b/src/BlockEntities/FlowerPotEntity.cpp index 5446ee5bd..60b2db4f5 100644 --- a/src/BlockEntities/FlowerPotEntity.cpp +++ b/src/BlockEntities/FlowerPotEntity.cpp @@ -59,6 +59,8 @@ bool cFlowerPotEntity::UsedBy(cPlayer * a_Player) return false; } + a_Player->GetStatManager().AddValue(Statistic::PotFlower); + cItem SelectedItem = a_Player->GetInventory().GetEquippedItem(); if (IsFlower(SelectedItem.m_ItemType, SelectedItem.m_ItemDamage)) { diff --git a/src/BlockEntities/FurnaceEntity.cpp b/src/BlockEntities/FurnaceEntity.cpp index f521bf666..e8e981065 100644 --- a/src/BlockEntities/FurnaceEntity.cpp +++ b/src/BlockEntities/FurnaceEntity.cpp @@ -139,6 +139,8 @@ bool cFurnaceEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) bool cFurnaceEntity::UsedBy(cPlayer * a_Player) { + a_Player->GetStatManager().AddValue(Statistic::InteractWithFurnace); + cWindow * Window = GetWindow(); if (Window == nullptr) { diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp index f7cb13b7d..9665b9f25 100644 --- a/src/BlockEntities/HopperEntity.cpp +++ b/src/BlockEntities/HopperEntity.cpp @@ -106,6 +106,8 @@ void cHopperEntity::SendTo(cClientHandle & a_Client) bool cHopperEntity::UsedBy(cPlayer * a_Player) { + a_Player->GetStatManager().AddValue(Statistic::InspectHopper); + // If the window is not created, open it anew: cWindow * Window = GetWindow(); if (Window == nullptr) diff --git a/src/BlockEntities/JukeboxEntity.cpp b/src/BlockEntities/JukeboxEntity.cpp index c8d08f327..6f25c4a36 100644 --- a/src/BlockEntities/JukeboxEntity.cpp +++ b/src/BlockEntities/JukeboxEntity.cpp @@ -70,6 +70,8 @@ bool cJukeboxEntity::UsedBy(cPlayer * a_Player) const cItem & HeldItem = a_Player->GetEquippedItem(); if (PlayRecord(HeldItem.m_ItemType) && !a_Player->IsGameModeCreative()) { + a_Player->GetStatManager().AddValue(Statistic::PlayRecord); + a_Player->GetInventory().RemoveOneEquippedItem(); return true; } diff --git a/src/BlockEntities/NoteEntity.cpp b/src/BlockEntities/NoteEntity.cpp index d56f45548..3e9958892 100644 --- a/src/BlockEntities/NoteEntity.cpp +++ b/src/BlockEntities/NoteEntity.cpp @@ -4,6 +4,7 @@ #include "NoteEntity.h" #include "../World.h" #include "json/value.h" +#include "../Entities/Player.h" @@ -33,7 +34,7 @@ void cNoteEntity::CopyFrom(const cBlockEntity & a_Src) bool cNoteEntity::UsedBy(cPlayer * a_Player) { - UNUSED(a_Player); + a_Player->GetStatManager().AddValue(Statistic::TuneNoteblock); IncrementNote(); MakeSound(); return true; -- cgit v1.2.3