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?

コマンドにおけるインライン表記について

1
Posted at

軽めに書きます

この記事は JavaEdition 26.3 にて動作確認を行っています

1. インラインとは

インライン(英: in-line, inline)は、

コマンド内で普通、データパックのJSONファイルのIDを指定しないといけない場面で
内容をそのまま書いてもいい というものです

predicateやloot_table、item_modifierなど色々できます

2. 実例

この説明では分かりづらいと思うので実例を上げます

例えば 現在が雨なら実行するコマンド を考えます。

まずは predicate を用意し...

is_rain.json
{
	"type": "minecraft:weather_check",
	"raining": true
}

コマンドを実行します

execute if predicate hoge:is_rain run ...

ちなみに hoge は メタ構文変数 と言い、わかりやすい解説は ここ にあります


これをインライン表記にすると、predicateファイルを用意せず...

execute if predicate {"type": "minecraft:weather_check", "raining": true} run ...

と、ファイルの中身を改行を消したうえで、書くことでも記述できる。というわけです

3. 意味

なぜインライン表記を行うのでしょうか?
それは...

シンプルなものなら、わざわざデータパック、ファイルを用意する意味がないから
つまり 面倒くさいから!!!

正直、これに尽きると思います。

4. 終わりに

ここまでのご清覧ありがとうございました。1

  1. ここまで言っておいてなんですが、
    実は私はあまりインライン表記が好きではないです。
    自分は持続可能な開発が好きですし、編集の過酷さなどを考えると...
    テストとかに使うといいかも ↩

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?