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
+13 -9

No files matched your search

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