Add player statistics to API (#5193)
* Fixed issue #5166 Co-authored-by: 12xx12 <44411062+12xx12@users.noreply.github.com> Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
This commit is contained in:
@@ -206,7 +206,7 @@ void cBeaconEntity::UpdateBeacon(void)
|
||||
(std::abs(Distance.z) <= 20)
|
||||
)
|
||||
{
|
||||
a_Player.AwardAchievement(Statistic::AchFullBeacon);
|
||||
a_Player.AwardAchievement(CustomStatistic::AchFullBeacon);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -313,7 +313,7 @@ bool cBeaconEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||
|
||||
bool cBeaconEntity::UsedBy(cPlayer * a_Player)
|
||||
{
|
||||
a_Player->GetStatManager().AddValue(Statistic::InteractWithBeacon);
|
||||
a_Player->GetStatistics().Custom[CustomStatistic::InteractWithBeacon]++;
|
||||
|
||||
cWindow * Window = GetWindow();
|
||||
if (Window == nullptr)
|
||||
|
||||
@@ -145,7 +145,7 @@ bool cBrewingstandEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||
|
||||
bool cBrewingstandEntity::UsedBy(cPlayer * a_Player)
|
||||
{
|
||||
a_Player->GetStatManager().AddValue(Statistic::InteractWithBrewingstand);
|
||||
a_Player->GetStatistics().Custom[CustomStatistic::InteractWithBrewingstand]++;
|
||||
|
||||
cWindow * Window = GetWindow();
|
||||
if (Window == nullptr)
|
||||
|
||||
@@ -204,11 +204,11 @@ bool cChestEntity::UsedBy(cPlayer * a_Player)
|
||||
|
||||
if (m_BlockType == E_BLOCK_CHEST)
|
||||
{
|
||||
a_Player->GetStatManager().AddValue(Statistic::OpenChest);
|
||||
a_Player->GetStatistics().Custom[CustomStatistic::OpenChest]++;
|
||||
}
|
||||
else // E_BLOCK_TRAPPED_CHEST
|
||||
{
|
||||
a_Player->GetStatManager().AddValue(Statistic::TriggerTrappedChest);
|
||||
a_Player->GetStatistics().Custom[CustomStatistic::TriggerTrappedChest]++;
|
||||
}
|
||||
|
||||
auto & PrimaryChest = GetPrimaryChest();
|
||||
|
||||
@@ -163,11 +163,11 @@ bool cDropSpenserEntity::UsedBy(cPlayer * a_Player)
|
||||
{
|
||||
if (m_BlockType == E_BLOCK_DISPENSER)
|
||||
{
|
||||
a_Player->GetStatManager().AddValue(Statistic::InspectDispenser);
|
||||
a_Player->GetStatistics().Custom[CustomStatistic::InspectDispenser]++;
|
||||
}
|
||||
else // E_BLOCK_DROPPER
|
||||
{
|
||||
a_Player->GetStatManager().AddValue(Statistic::InspectDropper);
|
||||
a_Player->GetStatistics().Custom[CustomStatistic::InspectDropper]++;
|
||||
}
|
||||
|
||||
cWindow * Window = GetWindow();
|
||||
|
||||
@@ -62,7 +62,7 @@ bool cEnderChestEntity::UsedBy(cPlayer * a_Player)
|
||||
return false;
|
||||
}
|
||||
|
||||
a_Player->GetStatManager().AddValue(Statistic::OpenEnderchest);
|
||||
a_Player->GetStatistics().Custom[CustomStatistic::OpenEnderchest]++;
|
||||
|
||||
// If the window is not created, open it anew:
|
||||
cWindow * Window = GetWindow();
|
||||
|
||||
@@ -50,7 +50,7 @@ bool cFlowerPotEntity::UsedBy(cPlayer * a_Player)
|
||||
return false;
|
||||
}
|
||||
|
||||
a_Player->GetStatManager().AddValue(Statistic::PotFlower);
|
||||
a_Player->GetStatistics().Custom[CustomStatistic::PotFlower]++;
|
||||
|
||||
cItem SelectedItem = a_Player->GetInventory().GetEquippedItem();
|
||||
if (IsFlower(SelectedItem.m_ItemType, SelectedItem.m_ItemDamage))
|
||||
|
||||
@@ -127,7 +127,7 @@ bool cFurnaceEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||
|
||||
bool cFurnaceEntity::UsedBy(cPlayer * a_Player)
|
||||
{
|
||||
a_Player->GetStatManager().AddValue(Statistic::InteractWithFurnace);
|
||||
a_Player->GetStatistics().Custom[CustomStatistic::InteractWithFurnace]++;
|
||||
|
||||
cWindow * Window = GetWindow();
|
||||
if (Window == nullptr)
|
||||
|
||||
@@ -113,7 +113,7 @@ void cHopperEntity::SendTo(cClientHandle & a_Client)
|
||||
|
||||
bool cHopperEntity::UsedBy(cPlayer * a_Player)
|
||||
{
|
||||
a_Player->GetStatManager().AddValue(Statistic::InspectHopper);
|
||||
a_Player->GetStatistics().Custom[CustomStatistic::InspectHopper]++;
|
||||
|
||||
// If the window is not created, open it anew:
|
||||
cWindow * Window = GetWindow();
|
||||
|
||||
@@ -65,7 +65,8 @@ bool cJukeboxEntity::UsedBy(cPlayer * a_Player)
|
||||
const cItem & HeldItem = a_Player->GetEquippedItem();
|
||||
if (PlayRecord(HeldItem.m_ItemType))
|
||||
{
|
||||
a_Player->GetStatManager().AddValue(Statistic::PlayRecord);
|
||||
a_Player->GetStatistics().Custom[CustomStatistic::PlayRecord]++;
|
||||
|
||||
if (!a_Player->IsGameModeCreative())
|
||||
{
|
||||
a_Player->GetInventory().RemoveOneEquippedItem();
|
||||
|
||||
@@ -34,7 +34,7 @@ void cNoteEntity::CopyFrom(const cBlockEntity & a_Src)
|
||||
|
||||
bool cNoteEntity::UsedBy(cPlayer * a_Player)
|
||||
{
|
||||
a_Player->GetStatManager().AddValue(Statistic::TuneNoteblock);
|
||||
a_Player->GetStatistics().Custom[CustomStatistic::TuneNoteblock]++;
|
||||
IncrementNote();
|
||||
MakeSound();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user