scoreboard コマンドで使えるすべての操作をまとめたリファレンスです。構文・パラメーター・使用例をすぐ引けるよう整理しています。
対応バージョン:Java Edition 1.21.11
objectives 操作
objectiveは「数値を格納する名前付きの箱」です。値を操作する前に必ず作成してください。
# 作成
scoreboard objectives add <名前> ["表示名"]
# 削除
scoreboard objectives remove <名前>
# 一覧をチャットに表示
scoreboard objectives list
# 表示場所を設定(場所を省略するとクリア)
scoreboard objectives setdisplay <場所> [名前]
# 表示名を変更
scoreboard objectives modify <名前> displayname <表示名>
# レンダータイプを変更
scoreboard objectives modify <名前> rendertype
criteria 一覧
criteria は「このobjectiveが何を自動で追跡するか」を決める種別です。dummy 以外は対応するゲームイベントが起きると自動でスコアが増減します。
汎用
| criteria | 説明 |
|---|---|
dummy | 自動変化しない汎用型。ポイント・フラグ・カウンターすべての基本 |
trigger | プレイヤーが /trigger で自分で変更できる。/triggerコマンドで管理者権限以外のプレイヤーも実行可能 |
戦闘・死亡
| criteria | 説明 |
|---|---|
deathCount | 死亡回数 |
playerKillCount | プレイヤーをキルした回数 |
totalKillCount | mob・プレイヤーを合わせた総キル数 |
ステータス
| criteria | 説明 | 備考 |
|---|---|---|
health | 現在のHP | 実際の値の×2(満タン=20) |
food | 現在の満腹度 | 0〜20 |
air | 現在の酸素残量 | 水中でのみ減少 |
armor | 防具値の合計 | 0〜30 |
xp | 経験値の総量(ポイント数) | |
level | 現在の経験値レベル |
行動ログ(minecraft.統計)
minecraft.<カテゴリ>:minecraft.<ID> の形式で書きます。コロンの後ろ(minecraft.<ID> の部分)が可変で、「何を対象にするか」を指定します。たとえば minecraft.mined:minecraft.stone なら「石を採掘した回数」、minecraft.mined:minecraft.diamond_ore に変えれば「ダイヤ鉱石を採掘した回数」になります。
| カテゴリ | IDに入れるもの | 検知する内容 |
|---|---|---|
minecraft.mined | ブロックID | そのブロックを採掘した回数 |
minecraft.crafted | アイテムID | そのアイテムをクラフトした回数 |
minecraft.used | アイテムID | そのアイテムを使用した回数 |
minecraft.picked_up | アイテムID | そのアイテムを拾った回数 |
minecraft.dropped | アイテムID | そのアイテムをドロップした回数 |
minecraft.broken | アイテムID | そのアイテムを耐久0で壊した回数 |
minecraft.killed | エンティティID | そのエンティティを倒した回数 |
minecraft.killed_by | エンティティID | そのエンティティに倒された回数 |
# ダイヤ鉱石を掘った回数
scoreboard objectives add dig_diamond minecraft.mined:minecraft.diamond_ore
# ダイヤの剣を壊した回数
scoreboard objectives add broke_sword minecraft.broken:minecraft.diamond_sword
# クリーパーを倒した回数
scoreboard objectives add kill_creeper minecraft.killed:minecraft.creeper
minecraft.custom:全項目一覧
minecraft.custom:<ID> はIDが固定のタイプで、ブロックやアイテムIDは入りません。以下がすべての項目です。
移動・行動
| criteria | 説明 |
|---|---|
minecraft.custom:minecraft.walk_one_cm | 歩いた距離(cm) |
minecraft.custom:minecraft.sprint_one_cm | ダッシュした距離(cm) |
minecraft.custom:minecraft.crouch_one_cm | スニーク移動した距離(cm) |
minecraft.custom:minecraft.swim_one_cm | 泳いだ距離(cm) |
minecraft.custom:minecraft.climb_one_cm | 壁を登った距離(cm) |
minecraft.custom:minecraft.fall_one_cm | 落下した距離(cm) |
minecraft.custom:minecraft.fly_one_cm | クリエイティブ飛行した距離(cm) |
minecraft.custom:minecraft.aviate_one_cm | エリトラで飛んだ距離(cm) |
minecraft.custom:minecraft.walk_on_water_one_cm | 水面を歩いた距離(cm) |
minecraft.custom:minecraft.walk_under_water_one_cm | 水中を歩いた距離(cm) |
minecraft.custom:minecraft.jump | ジャンプした回数 |
minecraft.custom:minecraft.sneak_time | スニーク状態だった時間(tick) |
乗り物
| criteria | 説明 |
|---|---|
minecraft.custom:minecraft.boat_one_cm | ボートで移動した距離(cm) |
minecraft.custom:minecraft.minecart_one_cm | トロッコで移動した距離(cm) |
minecraft.custom:minecraft.horse_one_cm | 馬に乗って移動した距離(cm) |
minecraft.custom:minecraft.pig_one_cm | ブタに乗って移動した距離(cm) |
minecraft.custom:minecraft.strider_one_cm | ストライダーに乗って移動した距離(cm) |
ダメージ・戦闘
| criteria | 説明 |
|---|---|
minecraft.custom:minecraft.damage_dealt | 与えたダメージ合計(実値×10) |
minecraft.custom:minecraft.damage_taken | 受けたダメージ合計(実値×10) |
minecraft.custom:minecraft.damage_absorbed | 吸収効果で無効化したダメージ(実値×10) |
minecraft.custom:minecraft.damage_resisted | 耐性効果で軽減したダメージ(実値×10) |
minecraft.custom:minecraft.damage_blocked_by_shield | シールドでブロックしたダメージ(実値×10) |
minecraft.custom:minecraft.damage_dealt_absorbed | 与えたが吸収効果で無効化されたダメージ(実値×10) |
minecraft.custom:minecraft.damage_dealt_resisted | 与えたが耐性効果で軽減されたダメージ(実値×10) |
minecraft.custom:minecraft.mob_kills | mobをキルした回数 |
minecraft.custom:minecraft.player_kills | プレイヤーをキルした回数 |
minecraft.custom:minecraft.deaths | 死亡回数 |
時間・セッション
| criteria | 説明 |
|---|---|
minecraft.custom:minecraft.play_time | プレイ時間(tick) |
minecraft.custom:minecraft.total_world_time | ワールドの総経過時間(tick) |
minecraft.custom:minecraft.time_since_death | 最後に死亡してから経過した時間(tick) |
minecraft.custom:minecraft.time_since_rest | 最後にベッドで寝てから経過した時間(tick) |
minecraft.custom:minecraft.leave_game | ゲームを退出した回数 |
アクション・インタラクション
| criteria | 説明 |
|---|---|
minecraft.custom:minecraft.sleep_in_bed | ベッドで寝た回数 |
minecraft.custom:minecraft.fish_caught | 魚を釣った回数 |
minecraft.custom:minecraft.animals_bred | 動物を繁殖させた回数 |
minecraft.custom:minecraft.drop | アイテムをドロップした回数(Qキー) |
minecraft.custom:minecraft.enchant_item | アイテムをエンチャントした回数 |
minecraft.custom:minecraft.play_noteblock | 音符ブロックを演奏した回数 |
minecraft.custom:minecraft.tune_noteblock | 音符ブロックを調律した回数 |
minecraft.custom:minecraft.play_record | レコードを再生した回数 |
minecraft.custom:minecraft.bell_ring | ベルを鳴らした回数 |
minecraft.custom:minecraft.pot_flower | 植木鉢に植えた回数 |
minecraft.custom:minecraft.target_hit | 的ブロックに当てた回数 |
minecraft.custom:minecraft.talked_to_villager | 村人と会話した回数 |
minecraft.custom:minecraft.traded_with_villager | 村人と取引した回数 |
minecraft.custom:minecraft.raid_trigger | レイドを発生させた回数 |
minecraft.custom:minecraft.raid_win | レイドに勝利した回数 |
minecraft.custom:minecraft.eat_cake_slice | ケーキをスライスで食べた回数 |
コンテナ・設備
| criteria | 説明 |
|---|---|
minecraft.custom:minecraft.open_chest | チェストを開いた回数 |
minecraft.custom:minecraft.open_barrel | 樽を開いた回数 |
minecraft.custom:minecraft.open_enderchest | エンダーチェストを開いた回数 |
minecraft.custom:minecraft.open_shulker_box | シュルカーボックスを開いた回数 |
minecraft.custom:minecraft.inspect_dispenser | ディスペンサーを開いた回数 |
minecraft.custom:minecraft.inspect_dropper | ドロッパーを開いた回数 |
minecraft.custom:minecraft.inspect_hopper | ホッパーを開いた回数 |
minecraft.custom:minecraft.trigger_trapped_chest | トラップチェストを開いた回数 |
minecraft.custom:minecraft.fill_cauldron | 大釜をバケツで満たした回数 |
minecraft.custom:minecraft.use_cauldron | 大釜からアイテムを取り出した回数 |
minecraft.custom:minecraft.clean_armor | 革防具を大釜で洗った回数 |
minecraft.custom:minecraft.clean_banner | バナーを大釜で洗った回数 |
minecraft.custom:minecraft.clean_shulker_box | シュルカーボックスを大釜で洗った回数 |
minecraft.custom:minecraft.interact_with_anvil | 金床を使った回数 |
minecraft.custom:minecraft.interact_with_beacon | ビーコンを使った回数 |
minecraft.custom:minecraft.interact_with_blast_furnace | 高炉を使った回数 |
minecraft.custom:minecraft.interact_with_brewingstand | 醸造台を使った回数 |
minecraft.custom:minecraft.interact_with_campfire | キャンプファイアを使った回数 |
minecraft.custom:minecraft.interact_with_cartography_table | 製図台を使った回数 |
minecraft.custom:minecraft.interact_with_crafting_table | 作業台を使った回数 |
minecraft.custom:minecraft.interact_with_furnace | かまどを使った回数 |
minecraft.custom:minecraft.interact_with_grindstone | 砥石を使った回数 |
minecraft.custom:minecraft.interact_with_lectern | 書見台を使った回数 |
minecraft.custom:minecraft.interact_with_loom | 機織り機を使った回数 |
minecraft.custom:minecraft.interact_with_smithing_table | 鍛冶台を使った回数 |
minecraft.custom:minecraft.interact_with_smoker | スモーカーを使った回数 |
minecraft.custom:minecraft.interact_with_stonecutter | 石切台を使った回数 |
setdisplay の場所一覧
| 場所 | 表示位置 |
|---|---|
sidebar | 画面右のサイドバー |
list | Tabキーのプレイヤー一覧横 |
belowName | プレイヤー名の下(頭上) |
sidebar.team.<color> | 指定チームカラーのサイドバー(例:sidebar.team.red) |
players 操作
# 加算
scoreboard players add <対象> <値>
# 減算
scoreboard players remove <対象> <値>
# 代入(上書き)
scoreboard players set <対象> <値>
# 取得(チャットに表示)
scoreboard players get <対象>
# 一覧表示
scoreboard players list [対象]
# スコアを削除(objectiveごと削除する場合は objectives remove を使う)
scoreboard players reset <対象> [objective]
# スコア同士の演算
scoreboard players operation <対象A> <演算子> <対象B>
operation の演算子一覧
| 演算子 | 意味 |
|---|---|
+= | A に B を加算 |
-= | A から B を減算 |
*= | A に B を乗算 |
/= | A を B で除算(整数・切り捨て) |
%= | A mod B(余り) |
= | A に B を代入(コピー) |
< | A = min(A, B) 小さい方をAに |
> | A = max(A, B) 大きい方をAに |
>< | A と B を交換(swap) |
trigger の使い方
trigger criteriaはスコアボードの中で特別な位置づけで、サバイバルモードのプレイヤーが自分自身のスコアを変更できる唯一のcriteriaです。通常、サバイバルモードのプレイヤーは scoreboard コマンドを実行できませんが、/trigger だけは例外的に使えます。プレイヤーにボタン的な入力をさせたいときに活用します。
準備:objectiveの作成と有効化
trigger を使うには、まずopやシステム側でobjectiveを作り、プレイヤーごとに「使用を許可」する必要があります。許可されていない状態でプレイヤーが /trigger を実行するとエラーになります。
# objectiveを trigger criteriaで作成
scoreboard objectives add menu trigger "メニュー選択"
# 対象プレイヤーの trigger を有効化(これをしないとプレイヤーが使えない)
scoreboard players enable @a menu
# 使用後にリセット・再有効化(1回きりにしたい場合はenableを省略)
scoreboard players set @a menu 0
scoreboard players enable @a menu
プレイヤー側のコマンド構文
| コマンド | 動作 |
|---|---|
/trigger <objective> | スコアに 1 を加算する |
/trigger <objective> add <値> | スコアに指定した値を加算する(マイナスも可) |
/trigger <objective> set <値> | スコアを指定した値に上書きする |
/trigger を実行すると、その objective の enable 状態が自動的に解除されます。再び使わせたい場合は、サーバー側で scoreboard players enable を再実行する必要があります。これを利用して「1人1回だけ押せるボタン」が簡単に作れます。
サーバー側での読み取りと処理(tick.mcfunctionとの組み合わせ)
プレイヤーが /trigger を実行したあと、そのスコアを execute if score で読み取って処理を分岐させるのが定番パターンです。処理後はスコアを 0 にリセットして再有効化します。
# tick.mcfunction(毎tick監視)
# スコアが 1 になったプレイヤーを検知して処理
execute as @a[scores={menu=1}] run function my_pack:menu_choice_1
execute as @a[scores={menu=2}] run function my_pack:menu_choice_2
# 処理済みのスコアをリセットして再度有効化
execute as @a[scores={menu=1..}] run scoreboard players set @s menu 0
execute as @a[scores={menu=1..}] run scoreboard players enable @s menu
使用例:参加時にモード選択させる
# setup.mcfunction
scoreboard objectives add mode trigger
# welcome.mcfunction(参加時に案内を表示して有効化)
scoreboard players enable @a mode
tellraw @a [{"text":"モードを選んでください。","color":"gold"}]
tellraw @a [{"text":"PvP参加 → ","color":"white"},{"text":"/trigger mode set 1","color":"aqua","clickEvent":{"action":"run_command","value":"/trigger mode set 1"}}]
tellraw @a [{"text":"観戦 → ","color":"white"},{"text":"/trigger mode set 2","color":"gray","clickEvent":{"action":"run_command","value":"/trigger mode set 2"}}]
# tick.mcfunction
execute as @a[scores={mode=1}] run function my_pack:join_pvp
execute as @a[scores={mode=2}] run function my_pack:join_spectator
execute as @a[scores={mode=1..}] run scoreboard players set @s mode 0
tellraw の clickEvent を使うとチャットのテキストをクリックするだけで /trigger が実行されます。プレイヤーが手動でコマンドを打つ手間がなくなり、GUIのような操作感を作れます。
注意:enable しないと使えない
objective を作っただけでは/triggerは実行できません。必ずscoreboard players enableでプレイヤーごとに使用を許可してください。参加時の welcome.mcfunction や tick.mcfunction での定期チェックと組み合わせて管理するのが定石です。
使用例
基本的なポイントカウンター
# setup.mcfunction(ワールドロード時に1回だけ実行)
scoreboard objectives add point dummy "ポイント"
scoreboard objectives setdisplay sidebar point
# ポイントを10加算
scoreboard players add @s point 10
# ポイントを0にリセット
scoreboard players set @s point 0
スコア同士の演算(合計を別objectiveに保存)
# total に point の値をコピーしてから bonus を加算
scoreboard players operation @s total = @s point
scoreboard players operation @s total += @s bonus
統計criteriaを使った採掘クエスト
# setup.mcfunction
scoreboard objectives add stone_mined minecraft.mined:minecraft.stone "石の採掘数"
scoreboard objectives setdisplay sidebar stone_mined
minecraft.mined 系のcriteriaは石を掘るだけで自動加算されます。players add で手動加算する必要はありません。
tellraw でスコアをチャットに埋め込む
tellraw @s [{"text":"あなたのポイント:","color":"gold"},{"score":{"name":"@s","objective":"point"},"color":"white"}]
よくある間違い
objectiveを作る前に players add を実行するとエラーになる
必ずobjectives addで作成してから値を操作してください。load.jsonに setup ファンクションを先に並べるのが定石です。
set と add を混同しやすい
set 0は「0にする(上書き)」、add 1は「今の値に1を足す」です。初期化にはset、カウンターにはaddを使います。
operation の除算 /= は整数除算(小数にならない)
7 /= 2 の結果は 3.5 ではなく 3 になります。小数が必要な場合は値を事前に10倍・100倍にしてから計算するのが定番の回避策です。
