Uploaded:2023/01/01 Latest-Update:2023/01/01

アドオン作成 - ファンクション

目次は右上の「≡」から!
使い方

複数のコマンドをまとめて実行したり、何度も使う長いコマンドを簡略化したりするのに使います。

ファイルの場所

ビヘイビアのfunctionsフォルダにファイルを置きます。その中にさらにフォルダを作れますが、コマンドが変わります。

ビヘイビア
  ┣ manifest.json
  ┣ pack_icon.png
  ┗ functions
    ┗〇〇.mcfunction

functionsフォルダ内のsystemフォルダにtest.mcfunctionを作った場合、コマンドは

/function system/test

になります。

書き方

非常にシンプルな書き方です。スラッシュ( / )なしでコマンドを書き連ねます。

give @a diamond_sword give @a cooked_beef 64 gamemode s @a time set day
コメントアウト

シャープ( # )を前に置くと、それ以降は改行されるまでコメントアウトとして無視されます。

# ダイヤ剣を渡す give @a diamond_sword # ステーキを64個渡す (実行しない) # give @a cooked_beef 64 # 全員のゲームモードをサバイバルにする gamemode s @a # 時刻を昼にする time set day
常時実行

functionsフォルダ内にファイル「tick.json」を作成することによって、指定したファンクションを常時実行させることができます。

ビヘイビア
  ┣ manifest.json
  ┣ pack_icon.png
  ┗ functions
    ┗tick.json

JSONの中身は以下のようになります。

{ "values": [ "my_function1", "my_function2", "my_function3" ] }

この例では三つのファンクション「my_function1」「my_function2」「my_function3」が常時実行されます。

具体例

ゲームルールをまとめてカスタム

gamerule commandblockoutput false gamerule sendcommandfeedback false gamerule showcoordinates true gamerule tntexplodes false gamerule domobloot false gamerule dotiledrops false gamerule dodaylightcycle false gamerule keepinventory true gamerule domobspawning false gamerule mobgriefing false gamerule doentitydrops false gamerule doweathercycle false time set noon title @p actionbar §aCustomed successfully

鉱石以外掘りぬき

fill ~-1 ~1 ~-1 ~11 -63 ~11 redstone_block 0 replace lava fill ~ ~1 ~ ~11 -63 ~11 air 0 replace seagrass fill ~ ~1 ~ ~11 -63 ~11 air 0 replace sea_pickle fill ~ ~1 ~ ~11 -63 ~11 air 0 replace coral fill ~ ~1 ~ ~11 -63 ~11 air 0 replace coral_fan fill ~ ~1 ~ ~11 -63 ~11 air 0 replace coral_fan_dead fill ~ ~1 ~ ~11 -63 ~11 air 0 replace coral_fan_hang fill ~ ~1 ~ ~11 -63 ~11 air 0 replace coral_fan_hang2 fill ~ ~1 ~ ~11 -63 ~11 air 0 replace coral_fan_hang3 fill ~ ~1 ~ ~11 -63 ~11 air 0 replace kelp fill ~ ~1 ~ ~11 -63 ~11 air 0 replace bubble_column fill ~-1 ~1 ~-1 ~11 -63 ~11 redstone_block 0 replace water fill ~ ~1 ~ ~10 -63 ~10 air 0 replace water fill ~ ~1 ~ ~10 -63 ~10 air 0 replace coral_block fill ~ ~1 ~ ~10 -63 ~10 air 0 replace ice fill ~ ~1 ~ ~10 -63 ~10 air 0 replace packed_ice fill ~ ~1 ~ ~10 -63 ~10 air 0 replace blue_ice fill ~ ~1 ~ ~10 -63 ~10 air 0 replace leaves fill ~ ~1 ~ ~10 -63 ~10 air 0 replace leaves2 fill ~ ~1 ~ ~10 -63 ~10 air 0 replace log fill ~ ~1 ~ ~10 -63 ~10 air 0 replace log2 fill ~ ~1 ~ ~10 -63 ~10 air 0 replace gravel fill ~ ~1 ~ ~10 -63 ~10 air 0 replace sand fill ~ ~1 ~ ~10 -63 ~10 air 0 replace sandstone fill ~ ~1 ~ ~10 -63 ~10 air 0 replace lava fill ~ ~1 ~ ~10 -63 ~10 air 0 replace stone 1 fill ~ ~1 ~ ~10 -63 ~10 air 0 replace stone 3 fill ~ ~1 ~ ~10 -63 ~10 air 0 replace stone 5 fill ~ ~1 ~ ~10 -63 ~10 air 0 replace grass fill ~ ~1 ~ ~10 -63 ~10 air 0 replace dirt fill ~ ~1 ~ ~10 -63 ~10 air 0 replace stone 0 fill ~ ~1 ~ ~10 -63 ~10 air 0 replace flowing_water fill ~ ~1 ~ ~10 -63 ~10 air 0 replace flowing_lava fill ~ ~1 ~ ~10 -63 ~10 air 0 replace podzol fill ~ ~1 ~ ~10 -63 ~10 air 0 replace clay fill ~ ~1 ~ ~10 -63 ~10 air 0 replace hardened_clay fill ~ ~1 ~ ~10 -63 ~10 air 0 replace redstone_block fill ~ ~1 ~ ~10 -63 ~10 air 0 replace deepslate fill ~ ~1 ~ ~10 -63 ~10 air 0 replace tuff title @p actionbar §l§aquarried successfully

インベントリ使えない縛り

replaceitem entity @p slot.inventory 0 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 1 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 2 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 3 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 4 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 5 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 6 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 7 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 8 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 9 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 10 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 11 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 12 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 13 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 14 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 15 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 16 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 17 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 18 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 19 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 20 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 21 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 22 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 23 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 24 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 25 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} } replaceitem entity @p slot.inventory 26 barrier 1 0 { "item_lock": { "mode": "lock_in_slot" }, "keep_on_death": {} }

できないこと
©2023 Rinca Hayamine