内科専門医 今日もマイクラ処方中

Minecraftの医学的有効性を検証中

MENU

超便利!Executeコマンド (day368)

超便利コマンドexecute.

これとコマンドブロックを駆使すれば出来ることが大幅に広がる。

Commands/execute – Minecraft Wiki

execute

1. executeとは

簡単に言うと、コマンドを他のentityなどに実行させることができる。

結果、同時に10回同じコマンドを実行させたり(entityが10匹いれば可能)、コマンド実行する場所を変えたりなどができるようになる。

 

2. サブコマンド subcommands

executeには4カテゴリー、12個のサブコマンドがある。

2.1. modify

コマンド実行をするentity (excutor)、場所 (position)、dimension、rotation、anchorを指定する。

2.2. condition

特定の条件を満たしているかチェック、結果やコマンド実行の条件を限定する

2.3. store

scoreboardの返ってきた数値やentity, block entity, storageのデータを格納する。

さらには、boss barの最大値や現在の値を変更できる。

2.4. run

コマンドを実行する。最後に配置する。

2.5. Basic rules

run以外のsubcommandsは複数使用可能。

subcommandsは左から右の順で実行される。

2.6. returning values

実行後、コマンドから返される数値には3つある: success value (0 or 1), result value (any integers), success count (0 or above)

success value (0 or 1), result value:

最後のsubcommandに由来する(conditionかrun)。

返される数値は整数である(四捨五入される)。

コマンドが途中で停止した場合、success, result valuesはともに0となる。

これらの数値はstore subcommandsで保存できる。繰り返しconditionかrunが実行されれば、その度に変更されていく。

success count (コマンドが成功した回数)

 

3. Modify subcommands

3.1. align

コマンドの実行位置をブロックポジションにする(整数)。指定した軸のみ。

/execute align xz

(-1.8, 2.3, 5.9) -> (-2, 2.3, 5)

3.2. anchored

コマンド実行の位置を目か足に指定する。Defaultは足。

execute anchored eyes run tp ^ ^ ^

により、コマンド実行者の足を、その目の位置にテレポートする。

3.3. as

コマンド実行者を指定する。position, rotation, dimension, anchorは変更させない。

/execute as <targets>

targets: entity

複数のentityが指定された場合、各々がコマンド実行する。

ex.) すべての豚のデータを取得する

execute as @e[type=sheep] run data get entity @s

3.4. at

コマンド実行するposition, rotation, and dimensionを指定する

/execute as @e[type=sheep] at @s run tp ~ ~1 ~

全ての羊を1マス上に移動させる。

3.5. facing

向く方向を指定

3.6. in

dimensionとpositionを決める

execute in minecraft:the_nether run tp ~ ~ ~

overworldにいる場合、その座標に該当するネザーの座標にテレポートする。

3.7. positioned

コマンド実行の位置をセットする

execute positioned 0 64 0 run locate structure #village

0 64 0に近い村の場所を知る。

3.8.rotated