1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Keystoneについて紹介します

Keystoneとは

統合版マインクラフトのビヘイビアパックで使用できるScriptAPIのラッパーライブラリとその動作環境を同梱したプロジェクトです。

コンセプト

  • ScriptAPIを使ったライブラリを作りたい
  • ScriptAPIを使ったライブラリ・プラグインのエコシステム(?)を作りたい

元々PMMPerでして、PMMPやその他サーバーソフトウェアのコミュニティのようにライブラリ・プラグインコミュニティが活性化できればいいなと思っています

開発手順

準備

Ubuntu or Mac (Windowsの人はWSL2を使って下さい)

Dockerのインストールから開発環境の構築まで一括でできます

 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/XxPMMPERxX/KeystoneCore/refs/heads/main/keystone-install.sh)"

共通

一度以下を実行すると必要なパッケージがインストールされます。

docker compose up -d dev

(npmが入っている人は以下でも良いです)

npm i

package.jsonのnameをあなたのプロジェクト名に変更

package.json
{
  "name": "<あなたのプロジェクト名>",
  "version": "1.0.0",
  "description": "<プロジェクトの説明>",
  ...
}

vite.config.app.js の uuid を変更
他の人とかぶると動作しなくなるので必ず変更しましょう。
ここのuuidを変更するときは worlds/DevWorld/world_behavior_packs.json の pack_id もここで設定したuuidと揃える必要があります。

vite.config.app.js
import { defineConfig } from 'vite';
import keystonePlugin from 'keystonemc/vite-plugin';

export default defineConfig({
  plugins: [keystonePlugin({ uuid: "<uuid>" })],
});

開発

src/index.ts に色々書いていきます。
もちろんファイル分割はできますが、index.ts は消さずに必ずエントリとして残しておいてください。

以下はサンプルで、プレイヤー参加時に「どうぶつの森」と表示されます

src/index.ts
import { EventManager } from 'keystonemc';

// 例:プレイヤーがスポーンした時
EventManager.registerAfter('playerSpawn', {
  handler(event) {
    if (!event.initialSpawn) return; // 初回参加時以外は無視
    event.player.sendMessage('どうぶつの森');
  }
});

開発サーバーを起動します。
開発サーバーを起動するとビルドが走り、dist_behavior_pack/ に成果物が出力されます。

docker compose up
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?