fix: totalMined改用遍历stats map(之前遍历所有方块读不到数据)

AW暴露StatsCounter.stats字段。之前遍历BuiltInRegistries.BLOCK用getValue(StatType,block)大多返回0,导致挖掘数偏低。
This commit is contained in:
AxTps committed 2026-10-06 20:25:40 +08:00
1 parent 1ee529eb5b
commit 72fbc95874
2 files changed
+7 -3

No files matched your search

@@ -31,11 +31,14 @@ public final class BoardSyncManager {
/** 排行榜最多显示条目数。 */ /** 排行榜最多显示条目数。 */
public static final int TOP_N = 10; public static final int TOP_N = 10;
/** 读取某玩家的挖掘总数(遍历所有方块的 BLOCK_MINED 累加)。 */ /** 读取某玩家的挖掘总数(遍历该玩家的 stats,累加 BLOCK_MINED 类型条目)。 */
private static int totalMined(ServerStatsCounter counter) { private static int totalMined(ServerStatsCounter counter) {
int sum = 0; int sum = 0;
for (Block block : BuiltInRegistries.BLOCK) { for (var entry : counter.stats.object2IntEntrySet()) {
sum += counter.getValue(Stats.BLOCK_MINED, block); Stat<?> stat = entry.getKey();
if (stat.getType() == Stats.BLOCK_MINED) {
sum += entry.getIntValue();
}
} }
return sum; return sum;
} }
+1
View File
@@ -4,3 +4,4 @@ accessible class net/minecraft/world/entity/monster/EnderMan$EndermanTakeBlockGo
accessible method net/minecraft/world/entity/Entity unsetRemoved ()V accessible method net/minecraft/world/entity/Entity unsetRemoved ()V
accessible field net/minecraft/world/entity/Entity entityData Lnet/minecraft/network/syncher/SynchedEntityData; accessible field net/minecraft/world/entity/Entity entityData Lnet/minecraft/network/syncher/SynchedEntityData;
accessible field net/minecraft/world/entity/Avatar DATA_PLAYER_MODE_CUSTOMISATION Lnet/minecraft/network/syncher/EntityDataAccessor;␍ accessible field net/minecraft/world/entity/Avatar DATA_PLAYER_MODE_CUSTOMISATION Lnet/minecraft/network/syncher/EntityDataAccessor;␍
accessible field net/minecraft/stats/StatsCounter stats Lit/unimi/dsi/fastutil/objects/Object2IntMap;