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.