
Fabric 及更新版本的 Minecraft 即将推出。

原版延迟(ping)/网络时延的计算在我看来一直 极其 不准确且存在滞后。
信息
它们每 30 秒才向客户端发送一次延迟值:
public void tick() {
if (++this.sendAllPlayerInfoIn > 600) {
this.broadcastAll(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.UPDATE_LATENCY, this.players));
this.sendAllPlayerInfoIn = 0;
}
}
而它们的“计算”方式如下:
int i = (int)(Util.getMillis() - this.keepAliveTime);
this.player.latency = (this.player.latency * 3 + i) / 4;
本模组绕过了原版的计算逻辑,使用类似自定义数据包来测量延迟,但对最近 5 次往返时间(RTT)的结果取合理的平均值。
此外,它还添加了一个可自定义的 HUD 元素,让你随时查看自己的延迟,并提供以下选项:
- 完全隐藏
- 将显示位置置于屏幕任意处
- 在同一 HUD 元素中显示最近 5 次延迟测量值
- 在服务器中其他玩家旁边以数值形式显示延迟读数,而非抽象的条形图(服务端有一个配置项,用于更改服务器向所有人广播这些值的频率)
默认值的示例配置
["Ping HUD"]
#启用延迟 HUD
pingHudEnabled = true
#额外显示最近 5 次延迟值
showPingQueue = false
#绘制带阴影的文字
drawTextWithShadow = true
#绘制延迟的位置:左侧为 true,右侧为 false
leftOrRight = true
#从屏幕边缘开始绘制的缩放 GUI 像素数量
#范围:> 0
horizontalPadding = 4
#从顶部开始绘制的行号
#范围:> 0
lineFromTop = 1
#从屏幕顶部开始绘制的缩放 GUI 像素数量
#范围:> 0
verticalPadding = 4
[Other]
#在玩家列表中显示毫秒数值的延迟
playerListNumbers = true
开启最近 5 次测量值、显示数值型玩家列表数据,并定位在屏幕右侧时的完整显示效果示例:

常见问题
问:支持 Forge 吗?
答:支持 Forge。
问:我可以在视频中使用你的模组吗?
答:只要你在视频中附上该模组(或整合包,如果它被包含在其中的话)的链接,完全可以。
问:我可以将你的模组添加到整合包中吗?
答:CurseForge/Modrinth 整合包没问题。

Fabric and newer Minecraft versions coming soon.

Vanilla ping/latency calculation always seemed incredibly inaccurate and delayed to me.
Info
They only send the latency value to clients once every 30 seconds:
public void tick() {
if (++this.sendAllPlayerInfoIn > 600) {
this.broadcastAll(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.UPDATE_LATENCY, this.players));
this.sendAllPlayerInfoIn = 0;
}
}
And this is how they "calculate" it:
int i = (int)(Util.getMillis() - this.keepAliveTime);
this.player.latency = (this.player.latency * 3 + i) / 4;
This mod goes around Vanilla and measures latency with a similar custom packet, but takes a proper average of 5 last RTT (round-trip-time) results.
Besides that, it also adds a customizable hud element to always see your ping with options such as:
- Hide completely
- Position anywhere on the screen
- Show last 5 latency measurements in the same hud element
- Show numerical readings for other players on the server instead of abstract bars (there is a config option serverside to change the frequency of the server broadcasting these values to everyone)
Example config with default values
["Ping HUD"]
#Enable ping HUD
pingHudEnabled = true
#Additionally show 5 last ping values
showPingQueue = false
#Draw text with a shadow
drawTextWithShadow = true
#Draw ping either on the left side (true), or on the right (false)
leftOrRight = true
#How many scaled GUI pixels to start drawing from the edge of the screen
#Range: > 0
horizontalPadding = 4
#On which line counting from the top to start drawing from
#Range: > 0
lineFromTop = 1
#How many scaled GUI pixels to start drawing from the top of the screen
#Range: > 0
verticalPadding = 4
[Other]
#Show numbers in milliseconds in player list
playerListNumbers = true
Example of a full display with the last 5 measurements turned on, numerical player list values, positioned on the right side of the screen:

FAQ
Q: Forge?
A: Forge.
Q: Can I include your mod in a video?
A: As long as you include a link to the mod/modpack (if it happens to be in one), absolutely
Q: Can I add your mod to a modpack?
A: CurseForge/Modrinth modpacks are cool.
评论 0
登录后参与评分
还没有评论,来抢沙发吧