Skip to content

代码架构与 Mixin 注入

本技术参考详细介绍了 速度计 (Speedometer) 的包层级结构、源码布局和 Mixin 注入目标分析。


📊 代码包架构图解

text
net.vanillaoutsider.speedometer
├── SpeedometerMod.java               <-- Constants & Identifier definitions
├── client
│   ├── SpeedometerClient.java        <-- ClientModInitializer entrypoint
│   ├── DebugEntrySpeedometer.java     <-- Custom DebugScreenEntry implementation
│   └── DebugEntryPlayerSpeedWrapper.java <-- Interceptor spy-wrapper for player_speed
└── mixin
    ├── DebugScreenEntriesMixin.java   <-- Hooks into DebugScreenEntries static init
    └── DebugScreenEntryListMixin.java <-- Enforces default IN_OVERLAY status

🧩 Mixin 注入目标对照清单

Mixin 类目标 Minecraft 原版类目标方法 / 注入点注入类型目的说明
DebugScreenEntriesMixinnet.minecraft.client.gui.components.debug.DebugScreenEntries<clinit> @At("TAIL")@Inject注册 speedometer 调试条目 ID,并在原生 player_speed 条目存在时进行包装拦截。
DebugScreenEntriesMixinnet.minecraft.client.gui.components.debug.DebugScreenEntriesregister@Invoker调用原版私有 register(Identifier, DebugScreenEntry) 注册方法。
DebugScreenEntryListMixinnet.minecraft.client.gui.components.debug.DebugScreenEntryListrebuildCurrentList @At("HEAD")@Inject确保 speedometer 的显示状态默认初始化为 DebugScreenEntryStatus.IN_OVERLAY

🔒 线程安全与非阻塞保障

  • 所有 Mixin 注入代码均严格独占运行在 Minecraft 客户端渲染线程中。
  • 零加锁的完全非阻塞式实现保证零掉帧 ($<0.001\text{ ms}$)。

🔗 相关页面

Official documentation & web portal for Dasik Igaijinn mods.