メインコンテンツまでスキップ
バージョン: Preview

playerBreakBlock

説明

プレイヤーがブロックを破壊したときにトリガーされるイベントです。


トリガータグ

イベントがトリガーされたとき、プレイヤーに自動付与されるタグです。

タグ名説明
capi:breakこのイベントがトリガーされたとき、プレイヤーに自動付与されます。
break:{ブロックID}破壊したブロックのIDがタグとして付与されます。

トリガースコア

イベントがトリガーされたとき、自動で更新されるスコアボードです。

スコアボード名説明
capi:break_x破壊したブロックのX座標です。
capi:break_y破壊したブロックのY座標です。
capi:break_z破壊したブロックのZ座標です。

使用例

基本的な検出

特定のブロックを破壊したプレイヤーを検出する例:

/execute as @a[tag=break:minecraft:diamond_ore] run say ダイヤモンド鉱石を破壊しました!
/tag @a remove break:minecraft:diamond_ore

複数のブロックタイプの検出

貴重な鉱石を破壊したプレイヤーを検出する例:

/execute as @a[tag=break:minecraft:diamond_ore] run tellraw @s {"rawtext":[{"text":"§bダイヤモンド鉱石を発見!"}]}
/tag @a remove break:minecraft:diamond_ore
/execute as @a[tag=break:minecraft:emerald_ore] run tellraw @s {"rawtext":[{"text":"§aエメラルド鉱石を発見!"}]}
/tag @a remove break:minecraft:emerald_ore
/execute as @a[tag=break:minecraft:ancient_debris] run tellraw @s {"rawtext":[{"text":"§6古代の残骨を発見!"}]}
/tag @a remove break:minecraft:ancient_debris

特定エリアでの破壊を検出

Y座標を使って地下での採掘を検出する例:

# 深い場所での採掘
/execute as @a[tag=capi:break,scores={capi:break_y=..16}] run title @s actionbar "§5深層採掘中..."

# 地表での作業
/execute as @a[tag=capi:break,scores={capi:break_y=60..}] run title @s actionbar "§a地表作業中"

/tag @a remove capi:break

ブロック破壊カウンター

特定のブロックの破壊数をカウントする例:

# 石ブロック破壊カウント
/execute as @a[tag=break:minecraft:stone] run scoreboard players add @s stone_broken 1
/execute as @a[tag=break:minecraft:stone,scores={stone_broken=1000..}] run tellraw @s {"rawtext":[{"text":"§6石ブロック1000個破壊達成!"}]}

# 原木破壊カウント
/execute as @a[tag=break:minecraft:oak_log] run scoreboard players add @s wood_broken 1
/execute as @a[tag=break:minecraft:birch_log] run scoreboard players add @s wood_broken 1
/execute as @a[tag=break:minecraft:spruce_log] run scoreboard players add @s wood_broken 1

禁止ブロックの破壊検出

特定のブロックの破壊を制限する例:

# スポーナーの破壊を検出
/execute as @a[tag=break:minecraft:spawner] run tellraw @s {"rawtext":[{"text":"§c警告:スポーナーを破壊しました!"}]}
/execute as @a[tag=break:minecraft:spawner] run scoreboard players add @s warning 1

実績システムとの連携

ブロック破壊に基づく実績を付与する例:

# 初めてのダイヤモンド
/execute as @a[tag=break:minecraft:diamond_ore,scores={diamond_found=0}] run tellraw @s {"rawtext":[{"text":"§b§l実績解除:最初のダイヤモンド!"}]}
/execute as @a[tag=break:minecraft:diamond_ore] run scoreboard players add @s diamond_found 1

# マスターマイナー
/execute as @a[tag=capi:break,scores={total_blocks_broken=10000}] run tellraw @s {"rawtext":[{"text":"§6§l実績解除:マスターマイナー(10000ブロック破壊)"}]}

時間帯による制限

特定の時間帯のみ特定のブロックの破壊を許可する例:

# 夜間のみ特殊鉱石を破壊可能
/execute if score time capi:world matches 13000..23000 as @a[tag=break:minecraft:diamond_ore] run give @s diamond 1
/execute if score time capi:world matches !13000..23000 as @a[tag=break:minecraft:diamond_ore] run tellraw @s {"rawtext":[{"text":"§cこの鉱石は夜間のみ採掘できます"}]}

ツールの使用状況を記録

どのツールで破壊したかを記録する例:

# ダイヤモンドのピッケルで破壊
/execute as @a[tag=capi:break,hasitem={item=diamond_pickaxe,location=slot.weapon.mainhand}] run scoreboard players add @s diamond_tool_use 1