fix: onClientRequest重发该objective的分数包(客户端空榜不显示)
sls_deaths分数值不变时服务端不发分数包,客户端收到空objective不渲染。改成请求时重发所有分数包(只发Score包避免重复创建)。
This commit is contained in:
1 parent
35b05eb044
commit
1c77347dc2
1 file changed
+10
-1
@@ -108,7 +108,16 @@ public final class BoardManager {
|
||||
: server.getScoreboard().getObjective(objectiveName);
|
||||
ServerMain.LOGGER.info("[SLSA-BOARD] onClientRequest player={} name={} obj={}",
|
||||
player.getScoreboardName(), objectiveName, obj);
|
||||
// 直接给该玩家发 display 包(slot=SIDEBAR,objective 可为 null 表示清除)
|
||||
// 给该玩家重发该 objective 的所有分数包(客户端可能没收到分数,导致空榜不显示)
|
||||
if (obj != null && server.getScoreboard() instanceof net.minecraft.server.ServerScoreboard ssb) {
|
||||
for (var pkt : ssb.getStartTrackingPackets(obj)) {
|
||||
// 只发分数包,不发 objective 定义包(避免客户端重复创建崩溃)
|
||||
if (pkt instanceof net.minecraft.network.protocol.game.ClientboundSetScorePacket) {
|
||||
player.connection.send(pkt);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 再发 display 包(slot=SIDEBAR,objective 可为 null 表示清除)
|
||||
player.connection.send(new net.minecraft.network.protocol.game.ClientboundSetDisplayObjectivePacket(
|
||||
net.minecraft.world.scores.DisplaySlot.SIDEBAR, obj));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user