Minecraft Bedrock Script API Starter Template – Free Download & Easy Setup Guide

Download here:

https://lemon-slime.com/resources/scriptAPI_template.zip

Overview:

This may seem sudden, but have you heard of the “Script API”? The “Script API” is a feature in the integrated version of Minecraft that allows you to customize the game system using a programming language (Javascript). With just knowledge of Javascript, you can tweak Minecraft’s systems to a certain extent. This isn’t possible in regular games. I like this aspect of Minecraft. Below is an example of the “Script API.”

Character
Incidentally, the Script API is part of an add-on.

However, using the Script API requires some prior preparation. This poses a certain hurdle for beginners, and some may stumble at this preparation stage. This is a real shame.

This article aims to provide a “Script API” template so you can skip this preparation step and start writing code right away. You can download it by clicking the link above. Please feel free to use it. For details on setting up the environment, please see this article.

How to Use:

First, download the zip file above. Next, create a folder in the com.mojang folder under development_behavior_packs and copy and paste all the template files into it. The com.mojang folder is located at C:\Users\(username)\AppData\Local\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang. The “AppData” file is hidden in File Explorer, so to select it, enable hidden files in File Explorer’s View settings. Alternatively, you can open it by launching the “Run” app and entering “%LocalAppData%\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang.” Once extraction is complete, try launching Minecraft. When launching the world, check the list of behavior packs. If “ScriptAPI Template” is one of them, the installation was successful.

Writing the Script:

Now that the basic preparations are complete, all that’s left is to write your own code. Open main.js in the scripts folder in the ScriptAPI_template folder you downloaded earlier. Any text editor, such as Notepad, will do (although we recommend using a specialized text editor like VSCode). You should see something like this:

import * as server from '@minecraft/server';

//Write your script here!
Copied!

The first line indicates that you’re using the minecraft/server module. This allows you to interact with the Minecraft world, so it’s essential when writing ScriptAPI. Write your script where it says “Write your script here” (this is a comment, so you can delete it or leave it in). Let’s actually write a script. Try copying and pasting the following:

server.system.runInterval(ev => {
    server.world.sendMessage("Hello!");
})
Copied!

The entire script looks like this. Save it and launch Minecraft.

Then, enable the “ScriptAPI Template” add-on and create a world. Can you see that “Hello!” is now displayed every tick? This is the effect of the “Script API”. This is how the “Script API” works. In a similar way, let’s create a script that triggers a command when an item is used. The template looks like this:

server.world.beforeEvents.itemUse.subscribe(ev => {
    if (ev.itemStack.typeId == "minecraft:stick"){
        ev.source.runCommandAsync("give @a diamond 1");
    }
})
Copied!

The above is an example where the command “give @a diamond 1” is triggered when a stick is used. Try arranging this to your liking to create your own original script. By the way, this article is very detailed about creating “usable items.” In addition to how to make any item usable, this article covers how to implement cooldowns, set conditions for item use, and how to implement multiple functions in a single item.

【マイクラ統合版】どんなアイテムでも右クリックで使用可能にする方法を解説 – クールダウンや使用条件も設定【ScriptAPI】
【マイクラ統合版】どんなアイテムでも右クリックで使用可能にする方法を解説 – クールダウンや使用条件も設定【ScriptAPI】
はじめに 先日の「ホリデークリエイターの特徴」の削除に伴って、オリジナルアイテムを使用した際の挙動をjsonファイル上で制御することができなくなりました。従って、使用可能なアイテムを作る場合、ScriptAPIの使用が前提となります。 ScriptAPIとは、javascriptというプログラミング言語を用いてゲームシステムをカスタマイズすることができる機能のことです。本アップデートに関する詳細については、こちらの記事をご覧ください。 https://lemon-slime.com/?p=1024 しかし、ScriptAPIの使用にあたっては、事前準備や基礎知識が必要です。ScriptAPIについてよくご存じでない方は、本記事を閲覧する前にこちらの記事に目を通していただくことをお勧めします。 https://lemon-slime.com/?p=1210 以下では、APIScriptについてご存じであることを前提に、どんなアイテムでも使用可能にする方法についてお話しします。 ScriptAPIを触るうえでの基本中の基本かも。 Youtube動画もあります 本記事の内容について詳細に解説したYoutube動画を制作しました。こちらから視聴できます。本動画では、キャラクターの掛け合い形式で分かりやすく説明することを目的としていますので、テキスト形式の情報が苦手な方は是非こちらもご覧いただくと理解が深まるかもしれません。 https://youtu.be/6uOLUTxmh_8 概要 SciptAPIのテンプレートをご使用の場合は、scriptフォルダ内のmain.jsを開いてください。まずは、いつも通り、import文を記述します(この文が既に存在する場合はこの処理は不要です)。 import * as server from '@minecraft/server'; コピー これによって、マインクラフトのモジュールを定義する変数serverの宣言が完了しました。以下でこのserverを用いていきます。 スクリプトを記述 いよいよ、スクリプトを記述していきます。任意のアイテムを使用可能にするにあたって、以下のプロセスを経てこれ実装しましょう。 アイテムが使用されたことを検知 使用されたアイテムが特定のものである場合、使用者の下でコマンド等を実行 例えば動画内にある通りの、「木の棒を使用したらダイアモンドが入手可能」というスクリプトは以下のようになります。 server.world.beforeEvents.itemUse.subscribe(ev => { if (ev.itemStack.typeId == "minecraft:stick"){ ev.source.runCommandAsync("give @a diamond 1"); } }) コピー 先のimport文のすぐ下にこの文章をコピー&ペーストしましょう。 このスクリプト自体は前の記事で登場していますが、本記事ではこのスクリプトに関して詳細な解説を行います。 解説 マインクラフトのモジュールにはworldクラスのbeforeEventsクラスが存在します。これは、ワールドにおける様々なイベントをトリガーし、イベントが起きたときに関数を起こすものです。これはScriptAPIにおいて非常によく使われるので、覚えておきましょう。今回は、その中のitemUseクラスを使用してアイテムが使用されたことを検知し、関数を発火させています。subscribe()関数は、ある関数の実行を約束するものです。このカッコの中に関数の内容を記述していきます。 関数の名前は、上記にある通り、ev(「event」の頭文字)です。 if文の中にあるev.itemStack.typeIdは、使用されたアイテムのidです(String型)。今回は、これがminecraft:stickと等しい場合にtrueが返され、次の処理に進みます。 ev.sourceは、イベントを起こしたエンティティです。今回は、棒を使用したプレイヤーですね。このエンティティの下で、runCommandAsync()関数でコマンドを実行します。今回はgiveコマンドとしました。これによって、棒を使用した際にダイアモンドが与えられます。 上記の「minecraft:stick」や「give @a diamond…

Writing Scripts:

As mentioned above, the Script API is based on JavaScript. Therefore, understanding JavaScript will make writing scripts easier. Here are some good books to help you master JavaScript.

created by Rinker
¥3,278 (2025/10/18 11:17:17時点 楽天市場調べ-詳細)

The official documentation is also a textbook for the Script API. It’s very helpful, so it’s definitely worth a read : https://learn.microsoft.com/ja-jp/minecraft/creator/scriptapi/minecraft/server/minecraft-server?view=minecraft-bedrock-experimental

For simple scripts, you can also use the ScriptAPI generator I created below. Please feel free to use it. Using the generator, you can easily implement scripts by simply copying and pasting:

【プログラミング不要】簡単ScriptAPIジェネレーター【マイクラ統合版】
【プログラミング不要】簡単ScriptAPIジェネレーター【マイクラ統合版】
Minecraft ScriptAPIジェネレーター 処理ブロック一覧 処理ブロックを追加 main.js プレビュー コピー ダウンロード OK キャンセル JavaScriptプレビュー XMLをエクスポート XMLをインポート 保存して閉じる 概要 「ScriptAPI、どんな関数があるのか分からない」 「何を書けばわからない」 そう思うこと、少なくないと思います。それを解決するべく作られたのが、本ページです! このページは、ScriptAPIを自動生成するジェネレーターです。上記の「処理ブロックを追加」を押してロジックブロックを追加してください。その後、生成されるロジックブロックをクリックすると鉛筆マークが表示されますので、それをクリックするとGUIによるプログラミングが可能です。 本ページは現在開発中です。不具合やバグなどありましたら、コメントなどでお知らせ願います。 生成されるJSファイルは右側にて表示されます。「コピー」または「ダウンロード」を押すことで出力されます。このスクリプトを、main.jsに貼り付けることで機能するかと思われます。 本ジェネレーターの詳細な使い方については、以下の動画でも解説しています: https://youtu.be/9cyNo6PaD5Q https://youtu.be/6ZycIkO-SV0 前提 ScriptAPIとは、マインクラフト統合版においてJavascriptというプログラミング言語を用いてゲームシステムをコントロールし、アドオンを制作できるシステムです。環境構築や具体的な概要などはこちらの記事が詳しいですので、併せてご覧ください: https://lemon-slime.com/game/minecraft/scriptapi-environment/ 何もしないアドオンは以下で作成できます。以下で作成したアドオンをベースに、BP/scripts/main.jsの内容を本ジェネレーターで作成したものに変更すると便利でしょう: https://lemon-slime.com/game/minecraft/addon-crafter/ 更新履歴 2025-08-30 : ver 1.0アップロード 2025-08-30 : 各種ブロック追加 / アイテム使用時に発火するイベント追加 2025-08-30 : システム・ワールド・スコアボードを追加/UIを若干変更 2025-08-30 : テンプレートを追加/日本語対応 2025-08-30 : フォームの制作に対応 2025-08-31 :…

Frequently used ScriptAPI phrases are summarized below. Combining these phrases allows you to write scripts efficiently:

【Minecraft統合版】よく使うAPI Scriptのフレーズ 5選
【Minecraft統合版】よく使うAPI Scriptのフレーズ 5選
はじめに みなさん、こんにちは!突然ですが、「API Script」をご存じでしょうか? 「API Script」というのは、マインクラフトの統合版において、プログラミング言語(Javascript)を用いてゲームシステムをカスタマイズできる機能のこと。Javascriptの知識さえあれば、マインクラフトのシステムをある程度いじることができるんです。普通のゲームはそんなことできません。マインクラフトのこういうところが私は好きです。 これは、APIスクリプト(ScriptAPI)の一例で、「ジャンプしたらkillコマンドが発動する」ことを意味しています。このようにしてゲームシステムに直接干渉するわけですね。 さて、本稿では、この「API Script」を使ったアドオンの制作において、ある程度よく用いられるフレーズを備忘録もかねて5つまとめてみたいと思います。あくまで「経験上」よく使われるか否かが論点であり、主観が多分に含まれていることに予めご了承ください。 個人的によく使うものをまとめてみました APIスクリプトの基本 本記事ではAPIスクリプトの基本事項については触れません。APIスクリプトの概要や基本事項、事前準備などについてはこちらの記事で詳細にまとめております。APIスクリプトの基本的な情報を知りたい方はまずこちらの記事を参照し、後で本記事に戻ることをお勧めします。 https://lemon-slime.com/?p=1210 以下では、APIスクリプトの基本を理解なさっていて、事前準備が完了していることを前提にお話しします。 本題 それでは、APIスクリプトの記述においてよく使われるフレーズをまとめます。 import文 API Scriptはimport文から始まります。これがなければただのjsファイルです。具体的には: import * as server from '@minecraft/server'; コピー のように記述し、これによって、マインクラフトの世界に干渉できるようになります。今のは一例で、人によっては、 from '@minecraft/server' import {world,system}; コピー のように書くこともあるらしいですね。好みが別れるところです。 言うまでもないですが、ここで同時に変数の宣言を行っています。以下で「server」という変数が突拍子もなく出てきますが、ここで宣言されたものです。 毎ティック実行 コマンドブロックに「常時実行」というモードがありますよね。これと同じように、常時プログラムを動かしたいときに重宝する関数があります。 server.system.runInterval(() => { //ここに内容を記述 }); コピー それがsystemクラスのrunInterval()です。これは、関数と間隔(int)を引数とすることで、名前の通り、一定周期で関数を実行することができます。上のように間隔を明記しない場合は常に実行します。常にプレイヤーの動きを監視するのにも使えます。ジャンプしたらkillされるAPI Script: にもこの関数が使われていますね。ちなみに、「常時実行」と言えば、functionsファイル内のtick.jsonを想起させます。ご存じのない方に向けて一応説明しますと、tick.jsonはワールド内で常時実行される関数スクリプト(一連のコマンド群で、mcfunction形式で記述されたもの)を定義します。このtick.jsonを用いることでも簡単に常時実行を達成することはできますが、こちらはあらかじめ定義されたコマンドしか使えないので一長一短です。必要に応じてrunInterval()とtick.jsonを使い分ける感じですね。 各プレイヤーについて実行 マインクラフトの主人公は、プレイヤーです。このプレイヤーを主体として何かを実行したいときもありますよね。そんな時に重宝するフレーズがあります。 for (const player of…

Customization:

Since this behavior pack is merely a template, the description and name of the add-on will indicate that it is a “template.” This is somewhat unsuitable for practical use.

To avoid this, you will need to modify the manifest.json file if you want to publish this script. The downloaded zip file should contain a file called manifest.json. This file contains the basic requirements of this add-on in JSON format, and its contents look like this:

You can change the add-on’s name and description by changing the name and description in this header, so please refer to this before publishing your script. We also recommend changing the UUID (a unique string specific to your add-on). It would be troublesome if it overlaps with other add-ons. You can automatically generate a UUID from the following external site:

https://www.uuidgenerator.net

You can also change the pack icon by overwriting pack_icon.png.

Conclusion:

This article provides a Script API template and explains basic information about the Script API and how to use it. Mastering the Script API will dramatically increase your freedom in Minecraft, so please give it a try! Questions about the Script API (including this template) are welcome in the comments section of this article or the YouTube video. Please share this article via social media link buttons, etc., as it will motivate the author.

Going deeper…

Your journey with APIScript doesn’t end here. For example, you can write scripts to display custom UIs. Below is an example.

How to Create a Custom UI with ScriptAPI in Minecraft Bedrock (Advanced Tutorial)
How to Create a Custom UI with ScriptAPI in Minecraft Bedrock (Advanced Tutorial)
Introduction Minecraft is a game with a huge degree of freedom. You can simply survive and defeat the Ender Dragon, master architecture and create highly artistic works, or even create maps for distribution using commands. The possibilities are truly endless.Now, creating add-ons further increases this freedom. Not only can you…

You can also build an APIScript environment from scratch to increase scalability and flexibility. For more details, please see here:

【マイクラ統合版】ScriptAPIの環境構築についてゼロから徹底解説 – スクリプトでゲームシステムを制御
【マイクラ統合版】ScriptAPIの環境構築についてゼロから徹底解説 – スクリプトでゲームシステムを制御
はじめに 突然ですが、皆さんは「ScriptAPI」をご存じでしょうか? 「ScriptAPI」というのは、マインクラフトの統合版において、プログラミング言語(Javascript)を用いてゲームシステムをカスタマイズできる機能のことを指します。Javascriptの知識さえあれば、マインクラフトのシステムをある程度いじることができるんです。以下は、その一例です。 これは、「プレイヤーがジャンプするとkillコマンドを発動する」というスクリプトです。このようにして、ゲームシステムに干渉し、カスタマイズすることができるわけですね。 本記事では、この「ScriptAPI」を記述するための準備段階として、環境構築について詳細に解説します。本記事を読むことで、上記のようにゲームシステムをカスタマイズし、オリジナルのアドオンを制作できるようになります。 手っ取り早くスクリプトを書きたい方へ 「事前準備はイヤだよ」 その気持ち、よく分かります。そのような声にお応えして、先日、「ScriptAPI」のテンプレートを作成いたしました。このテンプレートを用いることで、事前準備の段階を飛ばしてすぐにスクリプトを書き始めることができます。詳細についてはこちらの記事をご覧ください。 https://lemon-slime.com/?p=1210 ここでは、テンプレートを用いることなく、ゼロから環境構築を進めたい方に向けて必要な情報を提供します。 本題 さて、「ScriptAPI」の制作を始めるにあたって、必要なものがいくつか存在します。それは以下の表に示す通りです。 必要なソフト名 ダウンロード先 備考 Minecraft amazon 言わずと知れたゲームソフト。Win10版が望ましい。 vscode https://code.visualstudio.com/ コードの記述に特化したテキストエディタ(無料)。既に別のテキストエディタを持っている場合は不要。 node.js https://nodejs.org/ javascriptをパソコン上で実行するためのツール(無料)。ダウンロード後、msiファイルを実行。 必要なソフトのうち、Minecraftのみ有料で、その他は無料です。テキストエディタ(vscode)はなくても最悪できますが、あったほうが断然望ましいです。また、ScriptAPIはjavascriptに依存するので、このjavascriptをPC上で実行するためのnode.jsは必須です。 node.jsについては、別の方の記事ですが、こちらが非常に参考になりました。一応紹介いたします。 https://qiita.com/non_cal/items/a8fee0b7ad96e67713eb 環境構築 まず、com.mojangフォルダ内のdevelopment_behavior_packs内に移動し、新規にフォルダを作成します(名前は何でもいいです)。これがアドオンの作業フォルダとなります。com.mojangフォルダの場所については以下で説明します。既にご存じの場合は読み飛ばしてください。 com.mojangの場所 フォルダcom.mojangは C:\Users\(ユーザー名)\AppData\Local\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang に存在します。エクスプローラー上で、「AppData」というファイルは隠しファイルなので、これを選択するためには、エクスプローラーの「表示」設定から隠しファイルのチェックをオンにしてください。または、「ファイル名を指定して実行」というアプリを起動し、「%LocalAppData%\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang」と入力することでも開けます。 このcom.mojangの中にdevelopment_behavior_packsフォルダが存在するので、これを開いて新規にフォルダを作成してください。 manifest.jsonの作成 次に、新規に作成したアドオンのフォルダ内に移動し、「manifest.json」というjsonファイルを新規作成してください。右クリックして「新規作成」→「テキストドキュメント」を選択し、作成されるファイルの名前を「manifest.json」に変更すればOKです。 「manifest.json」はこのアドオンの要項(名前やidなど)を記述したファイルで、これによってマインクラフトがアドオンを認識できるようになります。 manifest.jsonの内容 作成したmanifest.jsonは先ほどダウンロードしたvscodeなどを用いて開くことができます。これを開き、以下をコピー&ペーストしてみましょう。 { "format_version": 2, "header": { "name": "スクリプトAPIのテンプレート", "description": "これはテンプレートです", "uuid": "b1ef9620-a18e-4fa3-bdca-f5f1d3c71c31",…
最新情報をチェックしよう!