Minecraft Creator Tools (mctools)
- Minecraft Creator Tools
- @minecraft/creator-tools - npm
- Mojang/minecraft-creator-tools: A set of tools for creating content and add-ons for Minecraft Bedrock Edition.
Minecraft の Add-On 開発を支援するツールです。 TypeScript での開発においては、このツールで簡単に雛形を作成できます。
インストール
Node.js が必要
未インストールであれば installing-nodejs-to-windows を参考に導入してください。
> npm install -g @minecraft/creator-tools
> mct --help
┌─────┐
│ ▄ ▄ │ Minecraft Creator Tools (preview) command line
│ ┏▀┓ │ See https://mctools.dev for more info.
└─────┘
Usage: mct [options] [command]
> mct eula --accept #なんらかのコマンドを入れると同意を求められるTypeScript プロジェクトの作成
まずはプロジェクトのフォルダを作成し、そのフォルダに移動します。
mkdir MinecraftTSSample
cd MinecraftTSSampleプロジェクトの初期化
mct create -o .
すると以下のような入力項目が順番に現れます。重要なのは What template should we use? の選択肢がある質問で tsStarter を選択することです。
✔ What's your preferred project title? MinecraftTSSample
✔ What's your preferred project description? My First Addon written in TS
✔ What's your creator name? your_name
✔ What's your preferred project short name? (<20 chars, no spaces)
? What template should we use?
addonStarter: Add-On Starter
❯ tsStarter: TypeScript Starter
addonFull: Full Add-On
editor-basics: Editor Add-on
dlStarter: Vibrant Visuals
cottaGame: Cotta Game with TypeScript
registeringExampleCustomComponent: Custom Components
Creating project 'MinecraftTSSample' from template 'tsStarter'...パッケージの導入・更新
mct create ではパッケージの初回のインストールまではやってくれないので以下のように npm install をまずは実行します。
その後、必要に応じて依存パッケージを最新にしておきます。(この記事の執筆時点では、 mct create で作成されたプロうジェクトは少し古いバージョンが導入されていたため)
# パッケージの導入
npm install
# パッケージの更新
npm install @minecraft/server@latest @minecraft/server-ui@latest @minecraft/math@latest @minecraft/vanilla-data@latest初回のビルド・デプロイ
以下のコマンドを実行することで、ローカルの Minecraft BE のアドオンの配置場所に出力されます。 Minecraft BE を起動し、Behaviour Pack や Resource Pack を確認してみてください。
npm run local-deployMinecraft BE のインストール場所
もし、インストール場所をカスタムしている場合には、
.envファイルの設定が必要になります。 以下の場所にインストールされていればデフォルトなので問題ありません。%%LOCALAPPDATA%\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang
パッケージング
作成したアドオンを配布したい場合には .mcaddon ファイルにパッケージしましょう。
npm run mcaddondist フォルダに .mcaddon ファイルが作成されます。
Git
Git でのソース管理をする場合には .gitignore が必要になります。
一般的な Node.js や TypeScript のものでも問題無いと思います。 もし迷うようであれば以下の Microsoft のサンプルプロジェクトなど、公式に近い場所で使われているものをベースにカスタマイズしていくといいと思います。 https://github.com/microsoft/minecraft-scripting-samples/blob/main/.gitignore