日本語 | English
AI を使って実装・文書化したプロジェクトです。 実装と文書の作成には OpenAI Codex を使用しています。
HMF は Minecraft Java Edition のデータパック向けの VS Code 拡張です。Storage の NBT やマクロ関数の引数の型を .hmf に宣言すると、対応する .mcfunction で型診断・補完・定義ジャンプを使えます。Minecraft は通常どおり .mcfunction を実行します。
インストールと動作確認
- デスクトップ版 VS Code 1.90 以降の拡張ビューで「VSIX からのインストール」を選び、HMF の VSIX を指定します。
pack.mcmeta があるデータパックを開き、次のファイルを置きます。複数のパックを扱う場合は共通の親フォルダーを開けます。
data/game/header/types.hmf
namespace game;
struct Player {
int hp;
}
storage game:runtime {
Player player;
}
data/game/function/main.mcfunction
data modify storage game:runtime player.hp set value 20
data modify storage game:runtime player.hp set value "full"
2 行目は Problems ビューに型不一致 HMF3001 を出します。 player. の直後で補完すると hp が候補に出ます。候補がほかの拡張と混ざる場合は「HMF: Storage の補完」を実行できます。player.hp の hp から F12 で定義へ移動できます。
リポジトリの examples/storage-demo と examples/shared-types-demo には、意図的に型エラーを含めた例があります。
検査と編集の範囲
| 対象 |
主な機能 |
| ヘッダー |
struct、class、単一継承、リスト、Optional、Union、型エイリアス、Enum |
| Storage |
NBT パス、リテラルの代入・マージ・リスト挿入、Storage 間コピー |
| マクロ関数 |
インライン引数、with storage、本体の $(引数名) |
| Entity・Block・Scoreboard |
対応する Entity 型とタグ、条件と対象が同じ座標の Block、scoreboard players set |
| Minecraft 固有型 |
リソース ID、Selector、UUID、1.20.5 以降の保存形式の Item Stack。コンポーネントの値検査は damage と custom_data に対応 |
| ナビゲーション |
型・NBT フィールド・マクロ引数などの定義や参照、型付き Function・Predicate ID から実ファイルへの移動 |
.hmf はアウトラインにも表示されます。F2 による名前変更は型名と、同一パック内でインライン呼び出しされるマクロ引数に対応します。型名の変更は宣言を参照する依存パックにも反映されます。変更先の名前が衝突する場合や、マクロ引数に with storage などの呼び出しがある場合は変更を中止します。
HMF の検査対象は、宣言とコマンドから型を解決できる箇所です。バニラコマンド全般の構文検査には Spyglass などを併用できます。HMF の give コンポーネント診断と補完は既定でオフです。
パックごとの設定
pack.mcmeta と同じ階層に hmf.config.json を置きます。VS Code は設定項目と候補を表示します。
{
"dependencies": ["../common"],
"typeChecking": {
"mode": "strict",
"unknownField": "warning"
}
}
| 設定 |
動作 |
include / exclude |
パックからの相対 glob でヘッダーを選択。既定の対象は data/**/*.hmf |
dependencies |
同じワークスペース内で参照するパックへの相対パス。依存先の依存先も参照 |
typeChecking.mode |
off、basic、normal(既定)、strict |
unknownStorage、unknownField、unknownMacroArgument、unknownResource |
typeChecking 内の診断レベル。 ignore、hint、info、warning、error |
typeChecking.giveComponents |
true で HMF の give 診断と補完を有効化 |
strict では未宣言の Storage と、索引にある名前空間の未知の Function・Predicate ID を既定で警告します。minecraft と未索引の名前空間は ID の存在確認の対象外です。依存先が見つからない場合や循環している場合は HMF5003 が出ます。ゲームで依存先の機能が必要な場合は、そのパックも Minecraft に導入してください。
CLI
リポジトリで Node.js 22 以降を使い、npm ci を実行します。VSIX を展開した場合も、同梱の extension/packages/cli/index.js を Node.js で直接実行できます。
npm run check -- examples/storage-demo
npm run --silent check -- examples/shared-types-demo --format json
npm run --silent check -- infer game:inferred_rewards examples/storage-demo/rewards.snbt
検査は保存済みのファイルを読みます。ディレクトリを省略するとカレントディレクトリを検査し、対象の下に複数のパックがあればまとめて検査します。終了コードは成功が 0、診断エラーが 1、引数や対象ディレクトリなどの問題が 2 です。--warnings-as-errors を指定すると警告でも 1 を返します。infer は SNBT からヘッダーの草案を生成して標準出力に書き出します。
開発
npm ci → npm test で検査できます。VS Code の「実行とデバッグ」から「HMF Extension」を起動すると、サンプルを開いた拡張開発ホストが起動します。配布ビルドとインストール検証の手順は docs/RELEASE.md を参照してください。
English
This project was implemented and documented using AI. OpenAI Codex was used to write code and documentation.
HMF is a VS Code extension for Minecraft Java Edition data packs. Declare Storage NBT and function macro argument types in .hmf files to get diagnostics, completion, and Go to Definition in supported .mcfunction commands. Minecraft runs the original .mcfunction files as usual.
Install and try it
- In desktop VS Code 1.90 or later, open the Extensions view, select Install from VSIX, and choose the HMF package.
- Open a data pack folder containing
pack.mcmeta. For several data packs, open their common parent.
- Add the following two files.
data/game/header/types.hmf
namespace game;
struct Player {
int hp;
}
storage game:runtime {
Player player;
}
data/game/function/main.mcfunction
data modify storage game:runtime player.hp set value 20
data modify storage game:runtime player.hp set value "full"
The second command reports a type mismatch (HMF3001) in the Problems view. Request completion after player. to see hp, or use the HMF: Storage の補完 command from the Command Palette. Press F12 on hp to open its definition. The repository's examples/storage-demo and examples/shared-types-demo include deliberate type errors for testing.
Features and scope
| Area |
Support |
| Headers |
Structs, classes, single inheritance, lists, optional fields, unions, type aliases, and enums |
| Storage |
NBT paths, literal assignments, merges, list insertions, and copies between storages |
| Function macros |
Inline arguments, with storage, and $(argument) placeholders |
| Entities, blocks, and scoreboards |
Supported entity type and tag matches, block guards that match the target coordinates, and scoreboard players set |
| Minecraft types |
Resource IDs, selectors, UUIDs, and the item stack format introduced in 1.20.5. Component value checking covers damage and custom_data |
| Navigation |
Outline, definition and reference navigation, and links from typed function and predicate IDs to their files |
F2 can rename declared types across dependent data packs and macro arguments used by inline calls in the same pack. Rename stops if the new name conflicts or a macro call uses with storage or another unsupported argument source. HMF checks supported commands where it can resolve a type. Use an extension such as Spyglass for broader vanilla command checking. HMF's give component diagnostics and completions are disabled by default.
Data pack configuration
Place an optional hmf.config.json next to pack.mcmeta. VS Code offers completion for supported settings and values.
{
"dependencies": ["../common"],
"typeChecking": {
"mode": "strict",
"unknownField": "warning"
}
}
| Setting |
Behavior |
include / exclude |
Pack-relative header globs. The default include pattern is data/**/*.hmf |
dependencies |
Relative paths to other packs in the same workspace, including their transitive dependencies |
typeChecking.mode |
off, basic, normal (default), or strict |
unknownStorage, unknownField, unknownMacroArgument, unknownResource |
Options under typeChecking that accept ignore, hint, info, warning, or error |
typeChecking.giveComponents |
Set to true to enable HMF's give component diagnostics and completions |
Strict mode warns by default about undeclared Storage and unknown function or predicate IDs in indexed namespaces. Existence checks skip the minecraft namespace and unindexed namespaces. Missing or circular dependencies report HMF5003. Install any data packs needed at runtime separately in Minecraft.
CLI and development
In the repository, use Node.js 22 or later and run npm ci. If you extracted the VSIX, you can also run its extension/packages/cli/index.js directly with Node.js.
npm run check -- examples/storage-demo
npm run --silent check -- examples/shared-types-demo --format json
npm run --silent check -- infer game:inferred_rewards examples/storage-demo/rewards.snbt
The checker reads saved files. It checks the current directory if no directory is specified and discovers data packs below it. Exit codes are 0 for success, 1 for diagnostics at error severity, and 2 for invocation problems. Use --warnings-as-errors to return 1 for warnings as well. The infer command writes a draft header to standard output.
Run npm test for automated tests, or launch HMF Extension from VS Code's Run and Debug view to open an Extension Development Host with the sample. See docs/RELEASE.md for packaging and installation tests.