架構與 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 原版類別 | 目標方法 / 注入點 | 注入類型 | 目的說明 |
|---|---|---|---|---|
DebugScreenEntriesMixin | net.minecraft.client.gui.components.debug.DebugScreenEntries | <clinit> @At("TAIL") | @Inject | 註冊 speedometer 調試條目 ID,並在原生 player_speed 條目存在時進行包裝攔截。 |
DebugScreenEntriesMixin | net.minecraft.client.gui.components.debug.DebugScreenEntries | register | @Invoker | 調用原版私有 register(Identifier, DebugScreenEntry) 註冊方法。 |
DebugScreenEntryListMixin | net.minecraft.client.gui.components.debug.DebugScreenEntryList | rebuildCurrentList @At("HEAD") | @Inject | 確保 speedometer 的顯示狀態預設初始化為 DebugScreenEntryStatus.IN_OVERLAY。 |
🔒 執行緒安全與非阻塞保障
- 所有 Mixin 注入程式碼均嚴格獨占運行在 Minecraft 客戶端渲染執行緒中。
- 零加鎖的完全非阻塞式實現保證零掉幀 ($<0.001\text{ ms}$)。
