一款轻量级的原版风格日夜与计时器 HUD 组件。使用主世界时钟时间,因此始终与可见的昼夜循环保持一致——无漂移、无需猜测、多人游戏中无同步问题。
整体设计旨在融入原版 UI:进度条复用 Minecraft 的经验值条精灵,HUD 图标显示实际的时间段(黎明、白天、黄昏、傍晚、夜晚),计数器放置在 HUD 元素应有的位置——包括自动避开Boss栏。
? 官方网站即将上线
我们正在为模组准备官方网站,届时您可以发现 upcoming projects(即将发布的项目)、通过工单系统报告问题,并提出想法或新功能建议。网站链接将在上线后添加到模组描述中。
该网站不会直接托管模组下载:所有模组仍将链接至 Modrinth,并继续仅从此平台下载。

? 1.4.7 更新内容
本次为修复版本,并更新了针对最新 Minecraft 26.4 快照的构建。没有新增功能,也没有对公共 API 进行修改;1.4.6 的所有内容仍然适用(详见下方的 For developers)。
- 里程碑音效不再每次重新进入世界时重复播放 —— 每个游戏会话中,一个里程碑日只庆祝一次。
- 过去的成就不再在首次打开已有世界时被标记为“今天”:模组现在会等待您的成就数据加载完成后,再估算每个成就是何时获得的。
- “睡眠时间”提醒不再出现在下界或末地,因为这些地方无法睡觉。
- 离开后立即重新进入世界,不再可能加载到略微过时的日志 —— 加载现在会等待上一个会话的背景保存完成。
- 实验性 Minecraft 26.4 jar 已更新至
26.4 Snapshot 7,该版本重写了菜单、HUD 和图像的绘制方式。需要 Snapshot 7 或更高版本以及 Fabric Loader 0.20.0+;启动正常,但尚未在游戏中进行实际测试。
请参阅此版本的变更日志以获取完整列表。

✨ 功能特性
- 当前世界天数计数器,在日期推进的瞬间有短暂脉冲动画(可切换)
- 日期显示格式:保留纯数字递增计数,或将其分组为周、月或年——这仅是视觉效果,不影响模组内部跟踪的任何内容
- 极限模式回顾:在主世界最终死亡时的常规死亡屏幕前,展示一个专用的“你存活了 N 天”界面,并附带来自你的 World Journal 的简短回顾
- 24小时制或12小时制时钟格式
- 使用原版经验值条精灵绘制的天数进度条,可选添加昼夜颜色滤镜——在下界期间变为纯红色,因为那里没有昼夜循环可供追踪
- 跟随实际游戏时间的黎明/白天/黄昏/傍晚/夜晚 HUD 图标——在下界替换为下界岩图标
- 手持指南针时在 HUD 标签中显示方向
- 情境化 HUD:显示你在当前下界访问中的停留时长——第一分钟内以秒为单位,之后以分钟为单位;此时时钟本身以下界特有的故障效果动画呈现,因为在其中读取具体时间毫无意义;或者显示你在极限模式世界中的生存连胜次数——同一时间只显示一项
- 接近足够晚的睡眠时间时显示的原版风格 Toast 提醒
- 在重要日子(50、100、365...)发出小型里程碑音效——可在设置界面关闭该音效,或选择播放哪种音效
- 9 种 HUD 位置预设(上/中/下 × 左/中/右),当 Boss 栏(龙、凋灵、袭击、服务器自定义栏,或大多数 OneBlock 风格的等级栏)可能与之重叠时,会自动缩小并移位——另设“额外顶部间距”选项作为手动后备方案,用于处理极少数在此共享通道之外绘制自身栏位的模组
- 如果安装了兼容模组,其他模组的自定义 HUD 栏可以堆叠在本计数器下方(或上方)——可在设置中切换
- 快速日志:按下专用按键即可打开一个小弹窗记录笔记,无需退出游戏或打开完整的 World Journal 书本
- 内置 Mod Menu 设置界面,分为四个标签页(HUD、信息与提醒、World Journal、键位绑定)——无需编辑配置文件,且本模组的两个按键可直接从“键位绑定”标签页重新绑定
- 完全客户端运行 —— 在任何服务器(原版或模组服)上使用均安全

? World Journal
从暂停菜单打开 World Journal:
- 为每个维度(主世界/下界/末地)的时代自定义命名,以契合你的游戏风格
- 自动里程碑,为你记录:首次访问下界、首次访问末地、击败末影龙,以及世界诞生 100/365/500/1000 天的纪念日 —— 如果你在加载模组前已经达成了某个里程碑,系统会进行回溯估算,而不是直接跳过
- 每次死亡,而不仅仅是第一次 —— 第一次死亡仍会特别标注
- 你防御或失败的每一次袭击
- 每次村民交易,并精确显示你获得的物品
- 你完成的每一个进度
- 生存连胜:记录你当前连续存活的天数,以及在该世界中曾经达到的最长连胜纪录
- 截图照片:在世界中按下 F2(Minecraft 自带的截图快捷键),截图会自动作为照片卡片保存到日志中,并附带日期、坐标和维度信息 —— 点击照片可为其添加标题和描述,或者通过暂停菜单中的“Screenshot”按钮即时拍摄。照片按天排列,呈现为微微倾斜、散落的簇状布局,类似真实的剪贴簿页面,点击后可查看大图预览。
- 每日天气:如果当天实际下雨或打雷,会被记录并显示
- 添加你自己的笔记,关联到当前的游戏内天数,可以通过书籍界面输入,或使用
/journal add 命令(见下方 Commands)
- 来自其他模组的条目,部分可能带有其专属图标,前提是你安装了兼容的模组
- 查看你每天收集的内容 —— 足够智能,不会将那些你原本就拥有、只是掉落又捡起的物品,或者在切换游戏模式后跟随你的物品计入统计
- 自动备份:每次加入世界时都会保留一份日志副本(最多保留最近 5 份),因此即使文件损坏也不会丢失整个日志
日志是按世界(单人游戏)或按服务器(多人游戏)保存的,存储在本地客户端上 —— 每位玩家拥有自己的独立日志。自动生成的条目(进度、死亡、袭击、交易、里程碑)始终会根据游戏当前设置的语言进行翻译显示,包括在不同语言会话期间记录的条目 —— 没有任何内容会永远停留在最初记录时的语言。你自己输入的笔记,或通过公共 API 由其他模组记录的条目,则保持原文不变。
? 修复了过往版本中的一个严重存储错误 — 如果你是从旧版本升级,请阅读此内容
在此 Minecraft 版本中,游戏报告单人游戏世界存档文件夹的方式可能出现错误,导致所有世界的路径解析为相同位置,而非各自独立的实际路径。因此,所有单人游戏世界最终共享同一个日志文件,而非各自拥有独立的日志 —— 一个全新世界可能会显示实际上发生在另一个完全不同世界中的条目。
此问题现已彻底修复:每个世界的日志都通过一个小隐藏标记文件与其各自的存档文件夹绑定,独立于文件夹名称。如果您是从修复前的版本升级,并且已经受到影响,那么打开一次单人世界列表就会显示一个恢复屏幕,提供选择是清空所有世界重新开始,还是选择哪个世界保留旧共享文件的条目。

? 控制键
- H — 打开 Vanilla DayTime Counter 的设置界面
- J — 打开快速日志弹窗,无需退出游戏即可记下笔记
这两个按键可以随时重新映射,既可以通过本模组的“键位绑定”设置选项卡,也可以通过 Minecraft 自带的“控制”菜单进行更改——两者会保持同步。

⌨️ 命令
客户端 /journal 命令,用于在不打开书本界面的情况下进行快速编辑:
/journal add <text> — 在当前游戏日内记录一条手动条目
/journal removeday <day> — 显示该日有多少条条目;执行 /journal removeday <day> confirm 将删除所有这些条目
/journal clear — 显示关于即将发生情况的警告;执行 /journal clear confirm 将永久清除当前世界的整个日志
removeday 和 clear 具有破坏性且无法撤销,这就是为什么它们都需要先单独输入 confirm 作为第二步,而不是立即执行的原因。

?️ 设置
从设置界面(现已拆分为 HUD、信息与警报、世界日志和键位绑定四个选项卡)中,您可以切换以下选项:
- 12 小时制 / 24 小时制时钟格式
- HUD 位置(9 种预设),以及针对顶部预设的“额外顶部留白”微调选项(关闭 / +20px / +40px / +60px)
- 天数计数器可见性及其变化脉冲动画
- 天数显示格式(默认 / 每周 / 每月 / 每年),以及最小显示单位在每个周期开始时重置还是继续累加
- 时钟可见性
- 进度条可见性及其日夜多色色调
- 指南针方向显示
- 上下文 HUD(下界访问计时器 / 极限模式生存连续天数)
- 自定义 HUD 进度条 — 一次性显示或隐藏由其他模组添加的所有进度条
- 纪元名称显示
- 睡眠提示框可见性
- 里程碑音效,开启/关闭及播放哪种声音
- 世界生日提示框
- 极限模式结束画面(“你存活了 N 天”回顾总结)的开启/关闭
- 截图照片捕获到日志中
- 每日天气追踪
- 快速日志按键启用/禁用
此外,在“键位绑定”选项卡中,可以重新映射本模组的按键(带有与原版冲突警告相同的提示),或者直接跳转到原版的完整键位绑定列表。
? 配置文件位置 — 供技术爱好者查阅
设置会保存到 Fabric 的配置文件夹中,文件名为:
vanilladaytimecounter.json
World Journal 数据按世界/服务器分别保存于 config/vanilladaytimecounter/worlds/,每个世界的已拍摄照片位于 config/vanilladaytimecounter/worlds/photos/,自动备份则保存在 config/vanilladaytimecounter/backups/。无需手动编辑——所有内容均可通过游戏内界面和 /journal 命令进行管理。

⚙️ 兼容性
发布了针对不同 Minecraft 版本的独立 jar 文件——请下载与你的游戏版本匹配的文件:
- Minecraft
26.1 — Fabric Loader 0.19.5+
- Minecraft
26.2 — Fabric Loader 0.19.5+
- Minecraft
26.3 — Fabric Loader 0.19.5+
- Minecraft
26.4 Snapshot 7 或更高版本(实验性快照构建)— Fabric Loader 0.20.0+
- 依赖: Fabric API
- 环境: 仅限客户端

❓ 常见问题
在我自己不管理的服务器上使用该模组是否安全?
是的——该模组完全在客户端运行。它不会修改服务器逻辑,不需要服务器端安装,且兼容原版或整合包服务器。
我的 World Journal 数据存储在哪里?会丢失吗?
数据仅存储在你本地的客户端中,按世界(单人游戏)或按服务器(多人游戏)区分——绝不会上传到任何地方。每次加入时都会自动保存一份备份(保留最近 5 份),因此存档损坏并不意味着整个日志丢失。自 1.4.2 版本起,存档写入更加安全:即使在保存过程中发生崩溃或断电,也不会再导致日志文件损坏。
在多人游戏中,我的计数器/日志与其他玩家看到的一致吗?
日/时间计数器始终与共享的主世界时钟同步,因此所有人看到的日期相同。World Journal 本身是玩家独立的:每位玩家记录自己的死亡、交易、成就和照片,并保留各自的本地副本。
关闭某个功能(天气、照片、里程碑音效……)是否会删除已记录的日志条目?
不会——设置仅控制未来要追踪或显示的内容。过去的日志条目保持不变。
我能否恢复更新模组之前的日志条目?
在安装之前已经达成的里程碑(世界生日、首次进入下界/末地等)会以回溯估算的方式呈现,而不会被跳过。如果你受到旧版单人游戏存档路径 bug 的影响,在更新后首次打开列表时会显示一次性的恢复屏幕——参见上方的 World Journal。
我可以隐藏其他模组添加的进度条吗?
可以——设置中的“自定义 HUD 栏”开关可以一次性隐藏所有第三方进度条,无需卸载添加这些进度条的模组。这不会影响该模组的任何其他内容。
此模组是否已避免与 OneBlock 风格的“等级”栏或其他 Boss 栏重叠?
对于任何通过原版自身 Boss 栏系统显示的栏——龙、凋灵、袭击,或由服务器/数据包通过 /bossbar 命令实现的栏(大多数 OneBlock 风格地图使用此命令实现其自身的“等级: X”栏)——是的,自动处理,无需设置。对于通过其他渠道自行绘制栏的模组,请使用设置 → HUD → HUD 位置中的新选项“额外顶部间距”,将此模组的 HUD 与其错开。
此模组会影响服务器性能或需要服务器端支持吗?
不会——它被声明为仅限客户端("environment": "client"),因此在服务器上没有任何影响。

? 面向开发者——API 持续扩展
Vanilla DayTime Counter 提供了一个小型公共 API(dev.notesow.vanilladaytimecounter.api.v1),以便其他 Fabric 模组可以基于此开发,而不是重新发明自己的日计数器。由于本模组的源代码不公开,以下将完整列出开发者所需的一切信息——没有单独的仓库或文档网站可供链接。
1.4.7 是一个修复版本——没有新增 API;其唯一涉及到的已记录行为是 DAY_MILESTONE_REACHED,现在确保在同一游戏会话中同一天重新加入世界时不再重复触发。1.4.6 也是一个修复版本——没有新增 API,除 getDeathCount() / 生存连击数不再计入重新显示的死亡画面外,下文记录的任何行为均无变化;同时 PHOTO_CAPTURED / getPhotoCount() 也不再包含在照片捕获功能关闭时截取的截图。1.4.5 是针对 Minecraft 26.3 的移植版本加一个修复;1.4.4 则是仅涉及稳定性和性能的发布。
1.4.3 新增: recordCustomCounter(Identifier) / recordCustomCounter(Identifier, int) 以及 getCustomCounterCount(Identifier) / getCustomCounterCount(Identifier, long) —— 通过本模组的日志提供通用的命名计数器,用于覆盖内置的死亡/袭击/交易/成就计数器未涵盖的内容。此外还有 DAY_MILESTONE_REACHED 事件(在本模组自身的开放式天数里程碑集上触发——50、365、每 100 的倍数),以及 getHudBlockBounds() / HudBlockBounds,以便其他模组能够确定本模组的 HUD 方块当前位置,并将其自身的 HUD 内容锚定到该位置(详见下方的“定位 HUD 方块”)。
1.4.2 新增功能: HudBar / HudBarRegistry,允许其他模组在此模组的 HUD 区块中直接绘制其自身的进度条(见下方的“绘制您自己的 HUD 进度条”)。此外还新增了:logCustomEvent(Identifier, String, Identifier icon) —— 与 logCustomEvent 相同,但在条目旁显示一个物品图标;以及 celebrateMilestone(Identifier, String, Identifier icon),它会以这种方式记录日志,并且在该 ID 首次被记录时播放此模组配置好的里程碑音效。
1.4.1 新增功能: 读取玩家当前的最长生存连胜时长、当前下界访问的持续时间、已拍摄的照片数量(及其日期/坐标/维度/标题/描述),以及每日记录的天气情况。此外还新增了 PHOTO_CAPTURED、WEATHER_CHANGED 和 WORLD_BIRTHDAY 事件,以及 PhotoRecord / WeatherRecord DTO。
1.4.0 新增功能: 读取玩家死亡次数、防御或输掉袭击的次数(现在包含具体哪些获胜 vs 失败)、与村民交易的次数(以及交易获得的物品),或完成的成就——每种统计都可以作为世界/服务器总计,或者限定为单个游戏日内。此外还新增了 JOURNAL_DAY_REMOVED / JOURNAL_CLEARED 事件,以便跟踪日志数据的模组能够收到通知,而不是在 /journal removeday / /journal clear 之后持有过时的状态。
? 你可以用它构建什么
- 进度/RPG 模组:在此 HUD 中绘制其自身的法力/耐力条,并在玩家收集了足够的特定材料、死亡次数过多、存活了足够长的时间或完成了特定成就后给予奖励。
- 恐怖模组:在特定日期触发脚本事件,或在玩家在黑暗后“外出时间过长”时首次触发。
- 伴侣模组:将其自身的里程碑记录到玩家的日志中,与此模组的自动记录并列(例如第一次击杀 Boss、第一次发现结构体等,取决于你的模组)——带有其专属图标,并为重大里程碑播放庆祝音效——通过命名计数器跟踪其自身进度——或对捕获的照片/天气变化做出反应。
- Boss/任务模组:通过
getHudBlockBounds() 绘制其自身的 HUD 进度条,使其锚定在(或与)此模组自身的区块对齐(或保持距离),而不是硬编码可能与其冲突的屏幕位置。
- 任何只需要可靠的“今天是哪一天/几点”而不需要重新实现主世界时钟数学逻辑的东西。
? 依赖此模组
没有发布的 Maven/Gradle 仓库或仅 API 工件——此模组使用 Gradle/Fabric Loom 构建,但仅作为本地构建,未发布到 Maven 仓库。要依赖它:获取构建好的 jar 文件(例如从发布版下载),按照添加任何其他 Fabric 模组 jar 作为本地文件依赖的方式,将其添加到你自己项目的编译时类路径中,并在你自己的 fabric.mod.json 中声明它:
"depends": {
"vanilladaytimecounter": ">=1.4.7"
}
(如果你只需要材质/日志/事件方法,这些方法较早版本就已提供,那么 >=1.3.7 就足够了;>=1.4.0 足以满足死亡/袭击/交易/成就计数器、getRaids() 以及日志移除事件的需求;>=1.4.1 足以满足生存连胜、下界访问时间、照片和天气的方法/事件/DTO 的需求;>=1.4.2 足以满足 HudBar / HudBarRegistry、logCustomEvent 的图标重载参数以及 celebrateMilestone 的需求;>=1.4.3 足以满足 recordCustomCounter / getCustomCounterCount、DAY_MILESTONE_REACHED 以及 getHudBlockBounds / HudBlockBounds 的需求。1.4.4 没有新增 API —— >=1.4.3 同样可用,>=1.4.4 仅额外保证该版本的稳定性/性能修复;1.4.5 也没有新增 API —— >=1.4.4 同样可用,>=1.4.5 仅额外保证 Minecraft 26.3 兼容性及该版本的修复;1.4.6 也没有新增 API —— >=1.4.5 同样可用,>=1.4.6 仅额外保证该版本的 bug 修复;1.4.7 也没有新增 API —— >=1.4.6 同样可用,>=1.4.7 仅额外保证该版本的 bug 修复。)你不需要进行任何注册或初始化调用——从 dev.notesow.vanilladaytimecounter.api.v1 导入类并直接使用,只要两个模组都已加载即可。由于这是一个仅限客户端的模组("environment": "client"),你的集成代码也应位于你客户端入口点/包中。
? 绘制您自己的 HUD 进度条 — HudBar / HudBarRegistry — 点击展开
你的进度条会自动堆叠在此模组自身的日期/时间 HUD 区块下方——或者在底部 HUD 位置预设的情况下堆叠在其上方,这样即使堆叠很高也不会超出屏幕——无论玩家选择了 9 个位置预设中的哪一个,甚至如果玩家关闭了此模组的所有 HUD 元素也是如此。
public static HudBar.Builder HudBar.builder(Identifier id, DoubleSupplier progress, IntSupplier color)
.icon(Identifier icon) // 可选:进度条左侧的 16x16 物品图标
.label(Supplier<String> label) // 可选:进度条右侧的文字
.visible(BooleanSupplier visible) // 可选;默认为始终可见
.build()
HudBarRegistry.register(HudBar bar) // 再次注册相同的 ID 会原地替换它
HudBarRegistry.unregister(Identifier id)
每个 Supplier 每帧 HUD 渲染时都会重新读取——无需自行调用更新方法。如果某个进度条的 Supplier 抛出异常,则该帧会被跳过(仅打印一次警告,而非大量刷屏),而不会破坏 HUD 或任何其他已注册的进度条。玩家可以通过此模组自身的“自定义 HUD 进度条”设置一次性隐藏所有第三方进度条,而无需卸载你的模组——请将你的进度条视为一种锦上添花的叠加层,而不是玩家严格依赖看到的内容。
注册您自己的法力条:
HudBarRegistry.register(
HudBar.builder(
Identifier.fromNamespaceAndPath("rpgmod", "mana"),
RpgModClient::currentManaFraction, // DoubleSupplier,取值范围 [0.0, 1.0]
() -> 0xFF3355FF) // IntSupplier,ARGB 蓝色
.icon(Identifier.withDefaultNamespace("lapis_lazuli"))
.label(() -> "Mana")
.build());
? 定位 HUD 区块 — HudBlockBounds — 点击展开
如果你想要绘制的元素无法通过上述 HudBar 表示为简单的堆叠行(例如你自己的首领风格血条、任务追踪器或任何具有自定义形状的元素),则可以通过你自身模组的 HUD 渲染钩子自行绘制,并使用 getHudBlockBounds() 来查找此模组自身的区块当前所在位置:
public static HudBlockBounds DayTimeApi.getHudBlockBounds()
public final int x, y, width, height; // GUI 缩放的屏幕像素;若不可见则为 0
public final boolean visible; // false = 此模组区块当前未绘制任何内容
请在你的每帧渲染回调内部调用它,而不是仅在启动时调用一次——该区块会随玩家选择的位置预设移动,并且可能逐帧调整大小。在使用坐标前始终检查 visible:
HudBlockBounds bounds = DayTimeApi.getHudBlockBounds();
int y = bounds.visible ? bounds.y + bounds.height + 6 : 8; // 位于其正下方,或作为后备值
drawMyQuestBar(graphics, y);
? 快速入门与更多示例 — 点击展开代码示例
package com.example.horrormod;
import dev.notesow.vanilladaytimecounter.api.v1.DayTimeApi;
import dev.notesow.vanilladaytimecounter.api.v1.DayTimeEvents;
import net.fabricmc.api.ClientModInitializer;
import net.minecraft.resources.Identifier;
public final class HorrorModClient implements ClientModInitializer {
private static final Identifier SCREAM_DAY_13 =
Identifier.fromNamespaceAndPath("horrormod", "heard_scream_day13");
@Override
public void onInitializeClient() {
DayTimeEvents.DAY_CHANGED.register(day -> {
if (day == 13 && !DayTimeApi.hasLoggedEvent(SCREAM_DAY_13)) {
triggerScareEffect();
DayTimeApi.logCustomEvent(SCREAM_DAY_13, "You heard a scream in the dark");
}
});
}
private void triggerScareEffect() { /* ... */ }
}
追踪你自身的命名计数器并在达到阈值时给予奖励:
Identifier wolvesFed = Identifier.fromNamespaceAndPath("rpgmod", "wolves_fed");
// 每当玩家喂食一只狼时:
DayTimeApi.recordCustomCounter(wolvesFed);
// 稍后在任何位置:
if (DayTimeApi.getCustomCounterCount(wolvesFed) >= 10) {
grantWolfWhispererTitle();
}
一个首领模组以与此模组庆祝其自身里程碑相同的方式庆祝击败事件——包括音效:
Identifier bossDefeated = Identifier.fromNamespaceAndPath("bossmod", "swamp_hag_defeated");
DayTimeApi.celebrateMilestone(bossDefeated, "Defeated the Swamp Hag",
Identifier.withDefaultNamespace("golden_apple"));
一个进阶/RPG 模组奖励长期的极限生存连胜记录,每天进行检查,以便在跨越阈值的瞬间触发奖励,而无需玩家重新打开菜单:
DayTimeEvents.DAY_CHANGED.register(day -> {
if (DayTimeApi.getCurrentSurvivalStreak() >= 50) {
grantSurvivorPerk();
}
});
响应此模组自身开放的每日里程碑集合,而不是自行推导哪些天数算作里程碑:
DayTimeEvents.DAY_MILESTONE_REACHED.register(day -> {
spawnCelebrationFireworks();
});
一个对此模组已追踪的天气做出反应的模组,而不是轮询世界自身的天气状态:
DayTimeEvents.WEATHER_CHANGED.register((day, weather) -> {
if (weather.thundered) {
spawnStormAmbiance();
}
});
一个镜像所有捕获到日志中的截图到自己的画廊功能的伴生模组,一旦玩家实际设置了标题/描述便将其拾取:
DayTimeEvents.PHOTO_CAPTURED.register((day, x, y, z, dimensionKey) -> {
queueForGallery(day, x, y, z, dimensionKey);
});
// 稍后,一旦玩家在《世界日志》书籍中有机会编辑过它:
for (PhotoRecord photo : DayTimeApi.getPhotos()) {
if (!photo.title.isEmpty()) {
updateGalleryEntry(photo);
}
}
一个向玩家已阅读的同个日志中添加自身里程碑的模组,使用 hasLoggedEvent 进行保护以确保仅记录一次,并以其自身模组 ID 而非 vanilladaytimecounter 作为命名空间:
Identifier firstBossKill = Identifier.fromNamespaceAndPath("bossmod", "first_boss_kill");
if (!DayTimeApi.hasLoggedEvent(firstBossKill)) {
DayTimeApi.logCustomEvent(firstBossKill, "Defeated the Swamp Hag");
}
? 读取当前状态 — DayTimeApi — 完整方法参考表
纯静态外观类:无实例,无需初始化调用,任何时间调用所有方法均安全。
DIMENSION_OVERWORLD、DIMENSION_NETHER、DIMENSION_END 是 getEraName 接受的字符串常量;任何其他字符串将无法匹配配置的纪元。
| 方法 |
返回值 |
未加载世界时 |
isWorldLoaded() |
是否当前加入了世界/服务器 |
false |
currentDay() |
当前游戏内天数,从 0 开始计数,基于主世界时钟计算得出 |
0 |
currentTimeOfDay() |
一天内的刻数,0–23999(0 黎明,6000 正午,12000 黄昏,18000 午夜) |
0 |
getEraName(String dimensionKey) |
玩家为维度设置的纪元名称,若未设置则为 "" |
"" |
listJournalEntries() |
所有日志条目,按天数升序排序,不可变快照 |
空列表 |
hasLoggedEvent(Identifier eventId) |
该确切的事件 ID 是否已被记录(包括本模组自动生成的里程碑) |
false |
logCustomEvent(Identifier eventId, String text) |
在当前天记录一条去重后的条目;text 为纯文本,而非翻译键;若 ID 已记录则无效操作 |
无效操作 + stderr 警告,永不抛出异常 |
logCustomEvent(Identifier eventId, String text, Identifier icon) |
同上,但在书本中的条目旁显示物品图标 |
无效操作 + stderr 警告,永不抛出异常 |
celebrateMilestone(Identifier eventId, String text, Identifier icon) |
同上,此外在本模组配置的里程碑音效首次记录此确切 ID 时播放 |
无效操作 + stderr 警告,永不抛出异常 |
getMaterialsCollectedOnDay(long day) |
物品 ID → 当天净收集量 |
空映射 |
getMaterialLog() |
完整的按天数升序的历史记录:天数 → (物品 ID → 数量) |
空映射 |
getDeathCount() / getDeathCount(long day) |
玩家死亡次数,总计或指定某一天 |
0 |
getCurrentSurvivalStreak() |
自上次死亡(或自第 0 天)以来存活的游戏内天数 |
0 |
getLongestSurvivalStreak() |
曾经达到的最长存活连续天数,包括仍在进行的这一次 |
0 |
getCurrentNetherVisitTicks() |
自进入下界起经过的实时刻数(20刻/秒),仅针对当前正在进行的访问;每次重新进入都会重置 |
0 |
getRaidCount() / getRaidCount(long day) |
已结束的袭击(无论输赢),总计或指定某一天 |
0 |
getRaids() / getRaids(long day) |
RaidRecord 快照,显示哪些袭击获胜或失败,按天数升序排序 |
空列表 |
getTradeCount() / getTradeCount(long day) |
村民交易完成次数(按交易次数计,而非按物品计),总计或指定某一天 |
0 |
getTrades() / getTrades(long day) |
TradeRecord 快照,显示获得了什么,按天数升序排序 |
空列表 |
getAdvancementCount() / getAdvancementCount(long day) |
带有可见标题的进度完成次数(隐藏/配方解锁类进度从不计入),总计或指定某一天 |
0 |
getCompletedAdvancements() / getCompletedAdvancements(long day) |
AdvancementRecord 快照,显示完成了哪些进度,按天数升序排序 |
空列表 |
getPhotoCount() / getPhotoCount(long day) |
捕获到日志中的照片截图数量,总计或指定某一天 |
0 |
getPhotos() / getPhotos(long day) |
PhotoRecord 快照,显示每张捕获的照片,按天数升序排序 |
空列表 |
getWeather(long day) |
Optional<WeatherRecord>,总结当天的雨/雷天气,晴朗或未追踪时为空 |
Optional.empty() |
recordCustomCounter(Identifier counterId) / recordCustomCounter(Identifier counterId, int amount) |
在当前天增加你自定义命名计数器的值(加 1,或加 amount) |
无效操作 + stderr 警告 |
getCustomCounterCount(Identifier counterId) / getCustomCounterCount(Identifier counterId, long day) |
你自定义计数器的累计总值,总计或指定某一天 |
0 |
getHudBlockBounds() |
本模组自身的 HUD 方块当前在屏幕上的绘制位置 |
一个 visible = false 的 HudBlockBounds |
listJournalEntries()、getMaterialLog()/getMaterialsCollectedOnDay() 以及 getTrades()/getCompletedAdvancements()/getRaids()/getPhotos() 均返回调用时刻的不可变快照,而非实时视图 —— 若要观察随时间的变化,请再次调用或使用下方所述的事件。计数器(死亡、袭击、交易、进度、照片以及你自己的自定义计数器)各有一个无参重载用于获取世界/服务器的总量,以及一个 (long day) 重载用于限定单个游戏内天数。
由早于 1.4.0 版本的此模组记录的袭击没有记录结果,因此它仍会计入 getRaidCount(),但不会出现在 getRaids() 中。玩家可以在设置中关闭天气追踪,在这种情况下 getWeather(long) 始终返回 Optional.empty()。
? 订阅事件 — DayTimeEvents — 完整事件参考表
每个事件都是一个静态的 ListenerList 字段;通常从 onInitializeClient 中调用 .register(listener) 进行注册一次。如果监听器抛出 RuntimeException,该异常会被捕获并记录日志 —— 这不会导致游戏崩溃或阻止其他监听器的执行。
| 事件 |
监听器签名 |
触发时机 |
DAY_CHANGED |
void onDayChanged(long day) |
游戏内日期发生变化时触发,并在玩家加入后立即触发一次(即使是第 0 天),从而免费获得一个基准值 |
JOURNAL_EVENT_LOGGED |
void onJournalEventLogged(JournalEntry entry) |
任何日志条目被记录时触发——包括本模组自动生成的里程碑、玩家的手动笔记(通过书籍界面或 /journal add 命令添加),或通过 logCustomEvent 由其他模组(或你自己)添加的自定义条目,且仅在条目已持久化保存到磁盘后触发 |
MATERIAL_COLLECTED |
void onMaterialCollected(Identifier itemId, int amount, long day) |
玩家对某物品的净持有量相比上一个客户端刻增加时触发;仅报告正向净增益,同一刻内的“拾取然后丢弃”可能不会被观察到(检测基于定期的库存快照) |
JOURNAL_DAY_REMOVED |
void onJournalDayRemoved(long day) |
执行 /journal removeday <day> confirm 命令清除某一天的所有条目、材料收集记录以及死亡/袭击/交易/进度记录 |
JOURNAL_CLEARED |
void onJournalCleared() |
执行 /journal clear confirm 命令清除整个日志 |
PHOTO_CAPTURED |
void onPhotoCaptured(long day, double x, double y, double z, String dimensionKey) |
一张新的截图被捕获并保存至日志中,此时玩家尚未有机会设置标题或描述 |
WEATHER_CHANGED |
void onWeatherChanged(long day, WeatherRecord weather) |
在当前新观测到下雨或雷暴时触发(一旦状态已为 true 则不再重复触发,晴天不会触发) |
WORLD_BIRTHDAY |
void onWorldBirthday(long day, long milestoneDays) |
世界达到预设的 100/365/500/1000 天里程碑之一 |
DAY_MILESTONE_REACHED |
void onDayMilestoneReached(long day) |
达到本模组自定义的开放式天数里程碑集合(50、365、每 100 的倍数)——即驱动其 HUD 庆祝动画和音效的同一组里程碑 |
? 数据传输对象 (DTOs) —— 逐字段参考
JournalEntry —— 不可变,包含四个公开的 final 字段:
public final long day; // 该条目所属的游戏内天数(从 0 开始计数)
public final String text; // 已解析的人类可读描述文本
public final Identifier sourceId; // 如果是在游戏中手动输入的则为 null;否则是谁记录的它
public final Identifier icon; // 除非是通过 logCustomEvent(id, text, icon)/celebrateMilestone 记录的则为 null
public boolean isManual(); // 等同于 sourceId == null 的简写
对于本模组自带的自动里程碑,sourceId 的命名空间为 vanilladaytimecounter;对于你自己记录的条目,则是你传递给 logCustomEvent 的确切 Identifier。
TradeRecord、AdvancementRecord 和 RaidRecord —— 分别由 getTrades()/getTrades(long)、getCompletedAdvancements()/getCompletedAdvancements(long) 和 getRaids()/getRaids(long) 返回。均为不可变对象,每个实例代表单次发生事件(例如一次交易交付了一组 3 个物品,这是一个 amount == 3 的记录,而不是三个独立的记录):
// TradeRecord
public final long day;
public final Identifier itemId; // 获得的物品,例如 minecraft:emerald
public final int amount; // 数量,已考虑堆叠大小
// AdvancementRecord
public final long day;
public final Identifier advancementId; // 例如 minecraft:nether/root
// RaidRecord
public final long day;
public final boolean victory; // true = 防御成功,false = 失败
PhotoRecord 和 WeatherRecord —— 分别由 getPhotos()/getPhotos(long) 和 getWeather(long) 返回:
// PhotoRecord
public final long day;
public final double x;
public final double y;
public final double z;
public final String dimensionKey; // DIMENSION_OVERWORLD / DIMENSION_NETHER / DIMENSION_END
public final String title; // 如果玩家尚未设置则为空字符串 ""
public final String caption; // 如果玩家尚未设置则为空字符串 ""
// WeatherRecord
public final long day;
public final boolean rained; // 当天任何时间点下过雨(或打过雷)
public final boolean thundered; // 当天任何时间点打过雷
HudBlockBounds —— 由 getHudBlockBounds() 返回:
public final int x;
public final int y;
public final int width;
public final int height;
public final boolean visible; // false = 当前未绘制任何内容;x/y/width/height 均为 0
PhotoRecord 刻意不暴露底层的截图图像文件:本模组的本地磁盘日志/照片存储不属于公共 API,且可能在任何时候无需通知即可更改。
? 规则与限制 —— 你不能做什么
- 为条目、进度条和计数器命名空间。
logCustomEvent/hasLoggedEvent/HudBar.builder/recordCustomCounter 均接受 Minecraft Identifier:始终使用您自己的模组 ID 作为命名空间(例如 Identifier.fromNamespaceAndPath("yourmod", "your_event")),切勿使用 vanilladaytimecounter —— 该命名空间保留给本模组自身的条目,使用它可能导致与它们发生冲突。
- 每个精确的事件 ID 在世界/服务器中只能记录一次。 不存在“在之后的某天再次记录此事件”的说法——如果需要可重复的触发器,请为每次出现生成一个新的 ID(例如将天数后缀加入其中,如
"scream_day_" + DayTimeApi.currentDay())。celebrateMilestone 的声音同样适用此规则:只有在给定 ID 首次被记录时才会播放。自定义计数器是例外——recordCustomCounter 不会进行去重处理,请在计数的事情发生时每次都调用它。
- 仅限客户端。 所有调用都必须在 Minecraft 客户端线程上执行,与其他任何 Fabric 客户端代码相同——没有服务端对应接口,也无法从专用服务器读取其他玩家的数据;需要这些数据的所有玩家都必须在自己的客户端上安装此模组。
api.v1 内无破坏性更改。 新功能以新增方法/事件的形式添加,绝不会通过更改现有内容来实现。假设性的破坏性更改将以新的 api.v2 包形式发布,与 api.v1 并存(而非替换)。此政策仅涵盖 dev.notesow.vanilladaytimecounter.api.v1——内部实现类(日志存储、文件格式、HUD 渲染)可以随时更改。
❓ 常见陷阱 — 点击展开
- 在
onInitializeClient 中读取 currentDay()/currentTimeOfDay() 会得到 0 / 无数据。 这是预期的行为:它在游戏启动时运行,此时尚未加入任何世界,因此 isWorldLoaded() 为 false。应在 onInitializeClient 中注册 DayTimeEvents 监听器(以及 HudBarRegistry.register 调用),但仅在加载了实际世界后,才从监听器/供应商回调内部读取“当前”值。
- 运行时出现
NoSuchMethodError / ClassNotFoundException,但编译正常。 您编译时所针对的 Vanilla DayTime Counter jar 版本与实际存在于 mods/ 中的版本不同。请确保您的 "depends" 约束与您编译时针对的 jar 匹配,并且 mods/ 中仅存在一个本模组 jar 的版本。
- 我注册的模组是否会收到自己记录的事件的通知? 是的——
logCustomEvent 会通过与其他条目相同的路径触发 JOURNAL_EVENT_LOGGED,包括向调用它的模组注册的监听器发送通知。如果您只想响应其他来源,请将 entry.sourceId 与您的命名空间进行比较并跳过它。
- 我注册的
HudBar 没有显示出来。 检查玩家自己的“自定义 HUD 进度条”设置是否开启,并确保您的 visible 供应商(如果设置了的话)确实返回 true——如果您未设置,进度条默认始终可见。
getHudBlockBounds() 一直返回 visible = false。 要么是您只在启动时调用了一次,而不是从您自己的每帧渲染回调中调用;要么是玩家真的关闭了此模组的所有 HUD 元素(或隐藏了整个 HUD,或未加载任何世界)——这并非您的问题,只是目前没有什么可以锚定而已。
- 注销监听器 可通过
ListenerList#unregister 完成,但前提是保留了传递给 register 的确切 lambda/实例引用——新编写的 lambda 是一个不同的对象,即使代码完全相同也不会匹配。
- Kotlin/Scala/Groovy 无需特殊适配器即可使用 —— 每种监听器类型都是普通的
@FunctionalInterface,且所有 DayTimeApi 方法均为静态 Java 方法。
? 许可说明
本模组的源代码保留所有权利:您可以下载并使用该模组,但其源代码未授权用于重新分发或修改。在编译时/运行时依赖已编译的 jar 来调用此公共 API——这是任何 Fabric 模组依赖另一个模组的正常方式——属于模组的正常使用,而非对其的重新分发或修改。使用您模组的玩家也需要安装 Vanilla DayTime Counter,这与任何其他 Fabric 模组依赖项的情况完全相同。
A lightweight, vanilla-style day and clock counter for the HUD. Uses the overworld clock time, so it always matches the visible day/night cycle — no drift, no guessing, no syncing issues in multiplayer.
The whole thing is built to blend into vanilla's own UI: the progress bar reuses Minecraft's XP bar sprites, the HUD icon shows the actual time of day (dawn, day, sunset, dusk, night), and the counter is placed exactly where a HUD element should live — including automatically staying out of the way of a boss bar.
? Official website coming soon
We are preparing the official website for our mods, where you will be able to discover upcoming projects, report issues through the ticket system, and suggest ideas or new features. The link will be added to the mod descriptions as soon as the website is available.
The website will not host mod downloads directly: all mods will remain connected to Modrinth and will continue to be downloaded exclusively from this platform.

? What's new in 1.4.7
A bug-fix release, plus an updated build for the latest Minecraft 26.4 snapshot. No new features and no changes to the public API; everything from 1.4.6 still applies as-is (see For developers below).
- The milestone sound no longer replays every time you rejoin a world on a milestone day — a milestone day is celebrated once per world per game session.
- Past advancements are no longer all dated "today" the first time you open an existing world with this mod: the mod now waits for your advancements to arrive before estimating when each was earned.
- The "Sleep time" reminder no longer appears in the Nether or the End, where you can't sleep.
- Rejoining a world right after leaving it can no longer load a slightly outdated journal — loading now waits for the background save of your previous session to finish.
- Experimental Minecraft 26.4 jar updated to
26.4 Snapshot 7, which reworked how menus, the HUD and images are drawn. Requires Snapshot 7 or newer and Fabric Loader 0.20.0+; it starts up cleanly but hasn't been play-tested in a world yet.
See this version's changelog for the full list.

✨ Features
- Current world day counter, with a brief pulse animation the moment the day advances (toggleable)
- Day display format: keep the plain running count, or group it into weeks, months, or years — purely visual, nothing this mod tracks internally is affected
- Hardcore run recap: a dedicated "You survived N days" screen, with a short recap from your World Journal, in front of the usual death screen on a hardcore world's final death
- 24-hour or 12-hour clock format
- Day progress bar drawn with vanilla XP bar sprites, with an optional day/night color tint — turns solid red instead while you're in the Nether, since there's no day/night cycle to track there
- Dawn/day/sunset/dusk/night HUD icon that follows the actual in-game time — replaced with a Netherrack icon in the Nether
- Compass direction shown in the HUD label while holding a compass
- Contextual HUD: shows how long you've been on your current Nether visit — in seconds for the first minute, then in minutes — with the clock itself rendering as an animated glitch effect there, since a time-of-day reading is meaningless in the Nether; or your current survival streak in a Hardcore world — only one shown at a time
- Vanilla-style toast reminder when it's getting late enough to sleep
- Small milestone sound on notable days (50, 100, 365...) — turn it off, or pick which sound plays, from the settings screen
- 9 HUD position presets (top/middle/bottom × left/center/right), with automatic shrink-and-shift when a boss bar (dragon, wither, raid, a server's own custom one, or most OneBlock-style level bars) would otherwise overlap it — plus an "Extra top clearance" setting as a manual fallback for the rare mod that draws its own bar outside that shared channel
- Custom HUD bars from other mods can appear stacked below (or above) this counter, if you have a compatible mod installed — toggleable in settings
- Quick Journal: a dedicated key opens a small popup to jot a note down without leaving gameplay or opening the full World Journal book
- Built-in Mod Menu settings screen, split into four tabs (HUD, Info & Alerts, World Journal, Keybinds) — no config file editing needed, and this mod's two keys can be rebound right from the Keybinds tab
- Fully client-side — safe to use on any server, vanilla or modded

? World Journal
Open the World Journal from the pause menu:
- Rename each dimension's era (Overworld/Nether/End) to whatever fits your playthrough
- Automatic milestones, logged for you: first Nether visit, first End visit, the Ender Dragon defeated, and world birthdays at 100/365/500/1000 days — if you'd already reached one before installing the mod, it's estimated retroactively instead of being skipped
- Every death, not just the first — the very first one is still called out specially
- Every raid you defend or lose
- Every villager trade, with exactly what you received
- Every advancement you complete
- A survival streak: how many days you've currently survived without dying, and your longest streak ever in that world
- Screenshot photos: press F2 (Minecraft's own screenshot key) in a world and the shot is automatically captured into the journal as a photo card, with the day, coordinates, and dimension recorded alongside it — click a photo to give it a title and description, or take one on the spot with the "Screenshot" button in the pause menu. Photos are laid out as a small, gently tilted, scattered cluster per day, like a real scrapbook page, with a large preview on click.
- Daily weather: whether it rained or thundered is recorded and shown on days it actually happened
- Add your own notes, tied to the current in-game day, either from the book screen or with the
/journal add command (see Commands below)
- Entries from other mods, occasionally with their own icon, if you have a compatible mod installed
- See what you've collected each day — smart enough to not count items you already owned that you only dropped and picked back up, or that followed you through a game mode switch
- Automatic backups: a copy of your journal is kept every time you join a world (the last 5 are retained), so a corrupted file doesn't mean losing your whole journal
Journals are per-world (singleplayer) or per-server (multiplayer), saved locally on your own client — every player keeps their own. Automatic entries (advancements, deaths, raids, trades, milestones) always show up translated into whatever language the game is currently set to, including entries logged in an earlier session under a different language — nothing stays stuck in the language it was originally logged in. Notes you typed yourself, or entries logged by another mod through the public API, are kept exactly as written.
? Fixed a serious storage bug from a past release — read this if you're upgrading from an older version
On this Minecraft version, the way the game reports a singleplayer world's own save folder could resolve to the same path for every world instead of that world's actual one, so every singleplayer world ended up sharing a single journal file instead of getting its own — a brand-new world could show entries that actually happened in a completely different world.
This is now fixed for good: each world's journal is tied to its own save folder through a small hidden marker file, independent of the folder's name. If you're upgrading from before that fix and had already been affected, opening the singleplayer world list once shows a recovery screen offering to either start every world clean or pick which world should keep the old shared file's entries.

? Controls
- H — open the Vanilla DayTime Counter settings screen
- J — open the Quick Journal popup, to jot down a note without leaving gameplay
Both keys can be remapped at any time, either from this mod's own Keybinds settings tab or from Minecraft's own Controls menu — both stay in sync.

⌨️ Commands
Client-side /journal commands, for quick edits without opening the book screen:
/journal add <text> — logs a manual entry on the current in-game day
/journal removeday <day> — shows how many entries exist for that day; /journal removeday <day> confirm deletes all of them
/journal clear — shows a warning about what's about to happen; /journal clear confirm permanently wipes the current world's entire journal
removeday and clear are destructive and can't be undone, which is why both require typing confirm as a separate step instead of running immediately.

?️ Settings
From the settings screen (now split into HUD, Info & Alerts, World Journal, and Keybinds tabs) you can toggle:
- 12-hour / 24-hour clock format
- HUD position (9 presets), plus an "Extra top clearance" fine-tune (Off / +20px / +40px / +60px) for the top presets
- Day counter visibility, and its change-pulse animation
- Day display format (Default / Weekly / Monthly / Annual), and whether the smallest shown unit resets each period or keeps counting up
- Clock visibility
- Progress bar visibility, and its day/night multicolor tint
- Compass direction display
- Contextual HUD (Nether visit timer / Hardcore survival streak)
- Custom HUD bars — show or hide every progress bar added by other mods at once
- Era name display
- Sleep-time toast visibility
- Milestone sound, on/off and which sound plays
- World birthday toast
- Hardcore end screen (the "You survived N days" recap) on/off
- Screenshot photo capture into the journal
- Daily weather tracking
- Quick Journal key enabled/disabled
And, from the Keybinds tab, rebind this mod's own keys (with the same conflict warning vanilla shows for clashing keys) or jump straight into vanilla's full key-binding list.
? Config file locations — for the technically curious
Settings are saved to Fabric's config folder as:
vanilladaytimecounter.json
World Journal data is saved per world/server under config/vanilladaytimecounter/worlds/, with each world's captured photos under config/vanilladaytimecounter/worlds/photos/, and its automatic backups under config/vanilladaytimecounter/backups/. No manual editing needed — everything is managed from the in-game screens and the /journal command.

⚙️ Compatibility
Separate jars are published, one per Minecraft version — download the one matching your game:
- Minecraft
26.1 — Fabric Loader 0.19.5+
- Minecraft
26.2 — Fabric Loader 0.19.5+
- Minecraft
26.3 — Fabric Loader 0.19.5+
- Minecraft
26.4 Snapshot 7 or newer (experimental snapshot build) — Fabric Loader 0.20.0+
- Requires: Fabric API
- Environment: Client-side only

❓ FAQ
Is it safe to use on a server I don't manage myself?
Yes — the mod is fully client-side. It doesn't touch server logic, doesn't require the server to have it installed, and works on vanilla or modded servers alike.
Where is my World Journal data stored, and can I lose it?
Locally on your own client, per world (singleplayer) or per server (multiplayer) — never uploaded anywhere. A backup copy is saved automatically every time you join (the last 5 are kept), so a corrupted save file doesn't mean losing your whole journal. Saves are also written more safely as of 1.4.2: a crash or power loss mid-save can no longer leave a corrupted journal file.
Will my counter/journal match what other players see in multiplayer?
The day/time counter always matches the shared overworld clock, so everyone sees the same day. The World Journal itself is per-player: each player logs their own deaths, trades, advancements, and photos, and keeps their own local copy.
Does turning off a feature (weather, photos, milestone sounds...) delete data already logged?
No — settings only control what gets tracked or shown going forward. Past journal entries stay exactly as they are.
Can I recover journal entries from before I updated the mod?
Milestones you'd already reached before installing (world birthdays, first Nether/End visit, etc.) are estimated retroactively instead of being skipped. If you were affected by the old singleplayer save-path bug, the world list shows a one-time recovery screen the first time you open it after updating — see World Journal above.
Can I hide progress bars added by other mods?
Yes — the "Custom HUD bars" toggle in Settings hides every third-party bar at once, without needing to uninstall whichever mod added them. It doesn't affect anything else in that mod.
Does this mod already avoid overlapping OneBlock-style "Level" bars or other boss bars?
For any bar shown through vanilla's own boss bar system — dragon, wither, a raid, or a server/datapack's own /bossbar command, which is how most OneBlock-style maps implement their own "Level: X" bar — yes, automatically, no setup needed. For a mod that draws its own bar through some other channel entirely, use the new "Extra top clearance" setting in Settings → HUD → HUD Position to nudge this mod's HUD clear of it.
Does this mod affect server performance or require anything server-side?
No — it's declared as client-side only ("environment": "client"), so it has zero footprint on the server.

? For developers — the API keeps growing
Vanilla DayTime Counter exposes a small public API (dev.notesow.vanilladaytimecounter.api.v1) so other Fabric mods can build on top of it instead of reinventing their own day counter. This mod's source isn't public, so everything a developer needs is written out below, in full — there's no separate repo or docs site to link to.
1.4.7 was a bug-fix release — no new API; the only documented behavior it touches is DAY_MILESTONE_REACHED, which now really doesn't fire again when the world is rejoined on the same day within a game session. 1.4.6 was a bug-fix release — no new API, no behavior changes to anything documented below beyond getDeathCount()/the survival streak no longer counting a re-shown death screen, and PHOTO_CAPTURED/getPhotoCount() no longer including screenshots taken while photo capture was turned off. 1.4.5 was a Minecraft 26.3 porting release plus one bug fix; 1.4.4 was a stability/performance-only release.
New in 1.4.3: recordCustomCounter(Identifier)/recordCustomCounter(Identifier, int) and getCustomCounterCount(Identifier)/getCustomCounterCount(Identifier, long) — generic named counters through this mod's journal, for anything the built-in death/raid/trade/advancement counters don't cover. Also new: the DAY_MILESTONE_REACHED event (fires on this mod's own open-ended day-milestone set — 50, 365, every multiple of 100), and getHudBlockBounds()/HudBlockBounds, so another mod can find out where this mod's HUD block currently is and anchor its own HUD content to it (see "Locating the HUD block" below).
New in 1.4.2: HudBar / HudBarRegistry, letting another mod draw its own progress bar directly in this mod's HUD block (see "Drawing your own HUD bar" below). Also new: logCustomEvent(Identifier, String, Identifier icon) — the same as logCustomEvent but with an item icon shown next to the entry — and celebrateMilestone(Identifier, String, Identifier icon), which logs like that and also plays this mod's own configured milestone sound the first time that id is logged.
New in 1.4.1: read the player's current and longest survival streak, how long they've been on their current Nether visit, how many photos have been captured (and their day/coordinates/dimension/title/description), and each day's recorded weather. Also new: PHOTO_CAPTURED, WEATHER_CHANGED, and WORLD_BIRTHDAY events, plus the PhotoRecord/WeatherRecord DTOs.
New in 1.4.0: read how many times the player has died, defended or lost a raid (now with which ones were won vs. lost), traded with a villager (and what they got), or completed an advancement — each either as a world/server total or scoped to a single in-game day. Also new: JOURNAL_DAY_REMOVED/JOURNAL_CLEARED events, so a mod tracking journal data gets notified instead of holding onto stale state after /journal removeday//journal clear.
? What you can build with it
- A progression/RPG mod that draws its own mana/stamina bar right in this HUD, and rewards the player once they've collected enough of a given material, died too many times, survived a long enough streak, or completed a specific advancement.
- A horror mod that triggers a scripted event on a specific day, or the first time the player has been "out too long" after dark.
- A companion mod that logs its own milestones into the player's journal alongside this mod's automatic ones (first boss kill, first structure found, whatever fits your mod) — with its own icon, and a little celebration sound for the big ones — tracks its own progress with a named counter — or reacts to a captured photo/weather change.
- A boss/quest mod that draws its own HUD bar anchored to (or clear of) this mod's own block via
getHudBlockBounds(), instead of hardcoding a screen position that might collide with it.
- Anything that just wants a reliable "what day/time is it" without re-implementing overworld-clock math.
? Depending on this mod
There's no published Maven/Gradle repository or API-only artifact — this mod is built with Gradle/Fabric Loom, but only as a local build, not published to a Maven repository. To depend on it: grab the built jar (e.g. from a release download), add it to your own project's compile-time classpath the same way you'd add any other Fabric mod jar as a local file dependency, and declare it in your own fabric.mod.json:
"depends": {
"vanilladaytimecounter": ">=1.4.7"
}
(>=1.3.7 is enough if you only need the material/journal/event methods, which shipped earlier; >=1.4.0 is enough for the death/raid/trade/advancement counters, getRaids(), and the journal-removal events; >=1.4.1 for the survival streak, Nether-visit timer, photo, and weather methods/events/DTOs; >=1.4.2 for HudBar/HudBarRegistry, the icon overload of logCustomEvent, and celebrateMilestone; >=1.4.3 for recordCustomCounter/getCustomCounterCount, DAY_MILESTONE_REACHED, and getHudBlockBounds/HudBlockBounds. 1.4.4 added no new API — >=1.4.3 is just as usable, >=1.4.4 only additionally guarantees the stability/performance fixes from that release; 1.4.5 added no new API either — >=1.4.4 is just as usable, >=1.4.5 only additionally guarantees the Minecraft 26.3 compatibility and fixes from that release; 1.4.6 added no new API either — >=1.4.5 is just as usable, >=1.4.6 only additionally guarantees the bug fixes from that release; 1.4.7 added no new API either — >=1.4.6 is just as usable, >=1.4.7 only additionally guarantees the bug fixes from that release.) No registration or init call is required on your side — import classes from dev.notesow.vanilladaytimecounter.api.v1 and use them directly, as soon as both mods are loaded. Because this is a client-only mod ("environment": "client"), your integration code should also live in your client-side entrypoint/package.
? Drawing your own HUD bar — HudBar / HudBarRegistry — click to expand
Your bar is stacked automatically below this mod's own day/time HUD block — or above it, on a bottom HUD position preset, so a tall stack never runs off-screen — regardless of which of the 9 position presets the player has picked, and even if the player has turned off every one of this mod's own HUD elements.
public static HudBar.Builder HudBar.builder(Identifier id, DoubleSupplier progress, IntSupplier color)
.icon(Identifier icon) // optional 16x16 item icon left of the bar
.label(Supplier<String> label) // optional text right of the bar
.visible(BooleanSupplier visible) // optional; defaults to always true
.build()
HudBarRegistry.register(HudBar bar) // registering the same id again replaces it in place
HudBarRegistry.unregister(Identifier id)
Every supplier is read fresh once per HUD frame — there's no update method to call yourself. A bar whose supplier throws an exception is skipped for that one frame only (with a single warning printed once, not a flood of them) instead of breaking the HUD or any other registered bar. The player can hide every third-party bar at once via this mod's own "Custom HUD bars" setting, without needing to uninstall your mod — treat your bar as a nice-to-have overlay, not something the player strictly depends on seeing.
Registering your own mana bar:
HudBarRegistry.register(
HudBar.builder(
Identifier.fromNamespaceAndPath("rpgmod", "mana"),
RpgModClient::currentManaFraction, // DoubleSupplier, in [0.0, 1.0]
() -> 0xFF3355FF) // IntSupplier, ARGB blue
.icon(Identifier.withDefaultNamespace("lapis_lazuli"))
.label(() -> "Mana")
.build());
? Locating the HUD block — HudBlockBounds — click to expand
If what you want to draw can't be expressed as a simple stacked row via HudBar above (your own boss-style bar, a quest tracker, anything with its own shape), draw it yourself through your own mod's HUD render hook, and use getHudBlockBounds() to find out where this mod's own block currently is:
public static HudBlockBounds DayTimeApi.getHudBlockBounds()
public final int x, y, width, height; // GUI-scaled screen pixels; all 0 if !visible
public final boolean visible; // false = this mod's block is drawing nothing right now
Call it from inside your own per-frame render callback, not once at startup — the block moves with the player's chosen position preset and can resize frame to frame. Always check visible before using the coordinates:
HudBlockBounds bounds = DayTimeApi.getHudBlockBounds();
int y = bounds.visible ? bounds.y + bounds.height + 6 : 8; // just below it, or a fallback
drawMyQuestBar(graphics, y);
? Quick start & more examples — click to expand code samples
package com.example.horrormod;
import dev.notesow.vanilladaytimecounter.api.v1.DayTimeApi;
import dev.notesow.vanilladaytimecounter.api.v1.DayTimeEvents;
import net.fabricmc.api.ClientModInitializer;
import net.minecraft.resources.Identifier;
public final class HorrorModClient implements ClientModInitializer {
private static final Identifier SCREAM_DAY_13 =
Identifier.fromNamespaceAndPath("horrormod", "heard_scream_day13");
@Override
public void onInitializeClient() {
DayTimeEvents.DAY_CHANGED.register(day -> {
if (day == 13 && !DayTimeApi.hasLoggedEvent(SCREAM_DAY_13)) {
triggerScareEffect();
DayTimeApi.logCustomEvent(SCREAM_DAY_13, "You heard a scream in the dark");
}
});
}
private void triggerScareEffect() { /* ... */ }
}
Tracking your own named counter and rewarding a threshold:
Identifier wolvesFed = Identifier.fromNamespaceAndPath("rpgmod", "wolves_fed");
// Every time the player feeds a wolf:
DayTimeApi.recordCustomCounter(wolvesFed);
// Later, anywhere:
if (DayTimeApi.getCustomCounterCount(wolvesFed) >= 10) {
grantWolfWhispererTitle();
}
A boss mod celebrating a defeat the same way this mod celebrates its own day milestones — sound and all:
Identifier bossDefeated = Identifier.fromNamespaceAndPath("bossmod", "swamp_hag_defeated");
DayTimeApi.celebrateMilestone(bossDefeated, "Defeated the Swamp Hag",
Identifier.withDefaultNamespace("golden_apple"));
A progression/RPG mod rewarding a long Hardcore survival streak, checked each day so the reward fires the moment the threshold is crossed instead of needing the player to reopen a menu:
DayTimeEvents.DAY_CHANGED.register(day -> {
if (DayTimeApi.getCurrentSurvivalStreak() >= 50) {
grantSurvivorPerk();
}
});
Reacting to this mod's own open-ended day-milestone set, instead of re-deriving which days count as milestones yourself:
DayTimeEvents.DAY_MILESTONE_REACHED.register(day -> {
spawnCelebrationFireworks();
});
A mod that reacts to the weather this mod already tracks, instead of polling the world's own weather state itself:
DayTimeEvents.WEATHER_CHANGED.register((day, weather) -> {
if (weather.thundered) {
spawnStormAmbiance();
}
});
A companion mod that mirrors every screenshot captured into the journal into its own gallery feature, picking up the title/description once the player has actually set them:
DayTimeEvents.PHOTO_CAPTURED.register((day, x, y, z, dimensionKey) -> {
queueForGallery(day, x, y, z, dimensionKey);
});
// Later, once the player has had a chance to edit it in the World Journal book:
for (PhotoRecord photo : DayTimeApi.getPhotos()) {
if (!photo.title.isEmpty()) {
updateGalleryEntry(photo);
}
}
A mod adding its own milestone into the same journal the player already reads, guarded with hasLoggedEvent so it only ever logs once, and namespaced under its own mod id rather than vanilladaytimecounter:
Identifier firstBossKill = Identifier.fromNamespaceAndPath("bossmod", "first_boss_kill");
if (!DayTimeApi.hasLoggedEvent(firstBossKill)) {
DayTimeApi.logCustomEvent(firstBossKill, "Defeated the Swamp Hag");
}
? Reading current state — DayTimeApi — full method reference table
Static-only facade: no instances, no init call needed, every method safe to call at any time.
DIMENSION_OVERWORLD, DIMENSION_NETHER, DIMENSION_END are the string constants accepted by getEraName; any other string just won't match a configured era.
| Method |
Returns |
When no world is loaded |
isWorldLoaded() |
whether a world/server is currently joined |
false |
currentDay() |
current in-game day, 0-based, derived from the overworld clock |
0 |
currentTimeOfDay() |
ticks within the day, 0–23999 (0 dawn, 6000 noon, 12000 dusk, 18000 midnight) |
0 |
getEraName(String dimensionKey) |
player-set era name for a dimension, or "" if unset |
"" |
listJournalEntries() |
all journal entries, sorted by day ascending, immutable snapshot |
empty list |
hasLoggedEvent(Identifier eventId) |
whether that exact event id was already logged (including this mod's own automatic milestones) |
false |
logCustomEvent(Identifier eventId, String text) |
logs a de-duplicated entry on the current day; text is plain text, not a translation key; no-op if the id was already logged |
no-op + stderr warning, never throws |
logCustomEvent(Identifier eventId, String text, Identifier icon) |
same, with an item icon shown next to the entry in the book |
no-op + stderr warning, never throws |
celebrateMilestone(Identifier eventId, String text, Identifier icon) |
same as above, plus this mod's configured milestone sound the first time this exact id is logged |
no-op + stderr warning, never throws |
getMaterialsCollectedOnDay(long day) |
item id → net amount collected that day |
empty map |
getMaterialLog() |
full day-ascending history: day → (item id → amount) |
empty map |
getDeathCount() / getDeathCount(long day) |
times the player died, total or on one day |
0 |
getCurrentSurvivalStreak() |
in-game days survived without dying since the last death (or since day 0) |
0 |
getLongestSurvivalStreak() |
the longest such streak ever reached, including one still in progress |
0 |
getCurrentNetherVisitTicks() |
real-time ticks (20/s) since entering the Nether on the current, ongoing visit; resets every re-entry |
0 |
getRaidCount() / getRaidCount(long day) |
raids that ended (won or lost), total or on one day |
0 |
getRaids() / getRaids(long day) |
RaidRecord snapshot of which raids were won vs. lost, sorted by day ascending |
empty list |
getTradeCount() / getTradeCount(long day) |
villager trades completed (per occurrence, not per item), total or on one day |
0 |
getTrades() / getTrades(long day) |
TradeRecord snapshot of what was received, sorted by day ascending |
empty list |
getAdvancementCount() / getAdvancementCount(long day) |
advancements with a visible title completed (hidden/recipe-unlock ones never count), total or on one day |
0 |
getCompletedAdvancements() / getCompletedAdvancements(long day) |
AdvancementRecord snapshot of which ones, sorted by day ascending |
empty list |
getPhotoCount() / getPhotoCount(long day) |
photo screenshots captured into the journal, total or on one day |
0 |
getPhotos() / getPhotos(long day) |
PhotoRecord snapshot of each captured photo, sorted by day ascending |
empty list |
getWeather(long day) |
Optional<WeatherRecord> summary of that day's rain/thunder, empty if clear/untracked |
Optional.empty() |
recordCustomCounter(Identifier counterId) / recordCustomCounter(Identifier counterId, int amount) |
increments your own named counter (by 1, or by amount) on the current day |
no-op + stderr warning |
getCustomCounterCount(Identifier counterId) / getCustomCounterCount(Identifier counterId, long day) |
your counter's running total, total or on one day |
0 |
getHudBlockBounds() |
where this mod's own HUD block is currently drawn on screen |
a HudBlockBounds with visible = false |
listJournalEntries(), getMaterialLog()/getMaterialsCollectedOnDay(), and getTrades()/getCompletedAdvancements()/getRaids()/getPhotos() all return immutable snapshots taken at call time, not live views — call again, or use the events below, to observe changes over time. The counters (deaths, raids, trades, advancements, photos, and your own custom ones) each have a no-arg overload for the world/server total and a (long day) overload scoped to one in-game day.
A raid logged by a version of this mod older than 1.4.0 has no recorded outcome, so it still counts toward getRaidCount() but won't appear in getRaids(). Weather tracking can be turned off by the player in settings, in which case getWeather(long) always returns Optional.empty().
? Subscribing to events — DayTimeEvents — full event reference table
Each is a static ListenerList field; call .register(listener) once, typically from onInitializeClient. Listeners that throw a RuntimeException are caught and logged — they don't crash the game or block other listeners.
| Event |
Listener signature |
Fires when |
DAY_CHANGED |
void onDayChanged(long day) |
the in-game day changes, and once immediately on join (even for day 0), so you get a baseline for free |
JOURNAL_EVENT_LOGGED |
void onJournalEventLogged(JournalEntry entry) |
any journal entry is logged — this mod's own automatic milestones, the player's manual notes (from the book screen or /journal add), or another mod's (or your own) custom entries via logCustomEvent, after it's already persisted to disk |
MATERIAL_COLLECTED |
void onMaterialCollected(Identifier itemId, int amount, long day) |
the player's net item count for something increases compared to the previous client tick; only positive net gains are reported, and a same-tick pick-up-then-drop may not be observed (detection is based on periodic inventory snapshots) |
JOURNAL_DAY_REMOVED |
void onJournalDayRemoved(long day) |
/journal removeday <day> confirm wipes one day's entries, materials, and death/raid/trade/advancement records |
JOURNAL_CLEARED |
void onJournalCleared() |
/journal clear confirm wipes the entire journal |
PHOTO_CAPTURED |
void onPhotoCaptured(long day, double x, double y, double z, String dimensionKey) |
a new screenshot is captured into the journal, before the player has had a chance to set a title/description |
WEATHER_CHANGED |
void onWeatherChanged(long day, WeatherRecord weather) |
rain or thunder is newly observed on the current day (not fired again once already true, and not fired for clear weather) |
WORLD_BIRTHDAY |
void onWorldBirthday(long day, long milestoneDays) |
the world reaches one of the built-in 100/365/500/1000-day milestones |
DAY_MILESTONE_REACHED |
void onDayMilestoneReached(long day) |
this mod's own open-ended day-milestone set is reached (50, 365, every multiple of 100) — the same set that drives its HUD celebration/sound |
? The DTOs — field-by-field reference
JournalEntry — immutable, four public final fields:
public final long day; // in-game day (0-based) this entry belongs to
public final String text; // already-resolved human-readable description
public final Identifier sourceId; // null if typed manually in-game; otherwise who logged it
public final Identifier icon; // null unless logged via logCustomEvent(id, text, icon)/celebrateMilestone
public boolean isManual(); // shorthand for sourceId == null
For this mod's own automatic milestones, sourceId is namespaced under vanilladaytimecounter; for entries you log yourself, it's exactly the Identifier you passed to logCustomEvent.
TradeRecord, AdvancementRecord, and RaidRecord — returned by getTrades()/getTrades(long), getCompletedAdvancements()/getCompletedAdvancements(long), and getRaids()/getRaids(long). All immutable, one instance per occurrence (a trade handing over a stack of 3 is one record with amount == 3, not three):
// TradeRecord
public final long day;
public final Identifier itemId; // what was received, e.g. minecraft:emerald
public final int amount; // how many, accounting for stack size
// AdvancementRecord
public final long day;
public final Identifier advancementId; // e.g. minecraft:nether/root
// RaidRecord
public final long day;
public final boolean victory; // true = defended, false = lost
PhotoRecord and WeatherRecord — returned by getPhotos()/getPhotos(long) and getWeather(long):
// PhotoRecord
public final long day;
public final double x;
public final double y;
public final double z;
public final String dimensionKey; // DIMENSION_OVERWORLD / DIMENSION_NETHER / DIMENSION_END
public final String title; // "" if the player hasn't set one yet
public final String caption; // "" if the player hasn't set one yet
// WeatherRecord
public final long day;
public final boolean rained; // rained (or thundered) at any point that day
public final boolean thundered; // thundered at any point that day
HudBlockBounds — returned by getHudBlockBounds():
public final int x;
public final int y;
public final int width;
public final int height;
public final boolean visible; // false = drawing nothing right now; x/y/width/height are all 0
The underlying screenshot image file is deliberately not exposed by PhotoRecord: this mod's on-disk journal/photo storage isn't part of the public API and may change at any time without notice.
? Rules & limits — what you can't do
- Namespace your own entries, bars, and counters.
logCustomEvent/hasLoggedEvent/HudBar.builder/recordCustomCounter all take a Minecraft Identifier: always use your own mod id as the namespace (e.g. Identifier.fromNamespaceAndPath("yourmod", "your_event")), never vanilladaytimecounter — that's reserved for this mod's own entries and using it risks colliding with them.
- Each exact event id can only be logged once, ever, per world/server. There's no "log this again on a later day" — if you need a repeatable trigger, mint a new id per occurrence (e.g. suffix the day number into it, like
"scream_day_" + DayTimeApi.currentDay()). Same rule applies to celebrateMilestone's sound: it only plays the first time a given id is logged. Custom counters are the exception — recordCustomCounter is not de-duplicated, call it every time the thing you're counting happens.
- Client-side only. Every call has to happen on the Minecraft client thread, same as any other Fabric client-side code — there's no server-side counterpart, and no way to read another player's data from a dedicated server; every player who needs this data must have the mod installed on their own client.
- No breaking changes within
api.v1. New capability is added as new methods/events, never by changing what's already here. A hypothetical breaking change would ship as a new api.v2 package alongside (not replacing) api.v1. Only dev.notesow.vanilladaytimecounter.api.v1 is covered by this policy — internal implementation classes (journal storage, file format, HUD rendering) can change at any time.
❓ Common gotchas — click to expand
- Reading
currentDay()/currentTimeOfDay() from onInitializeClient gives 0 / no data. That's expected: it runs at game startup before any world is joined, so isWorldLoaded() is false there. Register DayTimeEvents listeners (and HudBarRegistry.register calls) in onInitializeClient, but only read "current" values from inside a listener/supplier callback once a world is actually loaded.
NoSuchMethodError / ClassNotFoundException at runtime, but it compiles fine. You compiled against a different Vanilla DayTime Counter jar version than the one actually present in mods/. Make sure your "depends" constraint matches the jar you compiled against, and that only one version of this mod's jar exists in mods/.
- Will my own mod get notified about an event it logs itself? Yes —
logCustomEvent fires JOURNAL_EVENT_LOGGED through the same path as every other entry, including to listeners registered by the mod that called it. If you only want to react to other sources, check entry.sourceId against your own namespace and skip it.
- My registered
HudBar doesn't show up. Check the player's own "Custom HUD bars" setting is on, and that your visible supplier (if you set one) actually returns true — a bar defaults to always visible if you don't set one.
getHudBlockBounds() keeps returning visible = false. Either you're calling it once at startup instead of from your own per-frame render callback, or the player has genuinely turned off every one of this mod's HUD elements (or hidden the whole HUD, or no world is loaded) — nothing wrong on your end, there's just nothing to anchor to right now.
- Unregistering a listener works via
ListenerList#unregister, but only if you kept a reference to the exact lambda/instance passed to register — a freshly written lambda is a different object and won't match, even with identical code.
- Works from Kotlin/Scala/Groovy with no special adapter — every listener type is a plain
@FunctionalInterface and every DayTimeApi method is static Java.
? Licensing note
This mod's source is all-rights-reserved: you may download and use the mod, but its source is not licensed for redistribution or modification. Depending on the compiled jar at compile-time/runtime to call this public API — the normal way any Fabric mod depends on another — is ordinary use of the mod, not redistribution or modification of it. Players using your mod will need Vanilla DayTime Counter installed too, exactly like any other Fabric mod dependency.
评论 0
登录后参与评分
还没有评论,来抢沙发吧