From 72fbc95874b3fefc79587fb95847a91943e54e85 Mon Sep 17 00:00:00 2001 From: Ap_Tx <3045929398@qq.com> Date: Tue, 6 Oct 2026 20:25:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20totalMined=E6=94=B9=E7=94=A8=E9=81=8D?= =?UTF-8?q?=E5=8E=86stats=20map=EF=BC=88=E4=B9=8B=E5=89=8D=E9=81=8D?= =?UTF-8?q?=E5=8E=86=E6=89=80=E6=9C=89=E6=96=B9=E5=9D=97=E8=AF=BB=E4=B8=8D?= =?UTF-8?q?=E5=88=B0=E6=95=B0=E6=8D=AE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AW暴露StatsCounter.stats字段。之前遍历BuiltInRegistries.BLOCK用getValue(StatType,block)大多返回0,导致挖掘数偏低。 --- .../carpetslsaddition/util/BoardSyncManager.java | 9 ++++++--- src/main/resources/slsa.accesswidener | 13 +++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/github/zly2006/carpetslsaddition/util/BoardSyncManager.java b/src/main/java/com/github/zly2006/carpetslsaddition/util/BoardSyncManager.java index eae74d0..cbba629 100644 --- a/src/main/java/com/github/zly2006/carpetslsaddition/util/BoardSyncManager.java +++ b/src/main/java/com/github/zly2006/carpetslsaddition/util/BoardSyncManager.java @@ -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; } diff --git a/src/main/resources/slsa.accesswidener b/src/main/resources/slsa.accesswidener index 4e8cbad..348f032 100644 --- a/src/main/resources/slsa.accesswidener +++ b/src/main/resources/slsa.accesswidener @@ -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; \ No newline at end of file +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; \ No newline at end of file