@なぎ-q7g

コマンド解説めっちゃ分かりやすいです。感謝 チャンネル登録しました。

@猫様に従え

めんどくさいかもしれないけど、コメント欄にコマンド書いていてくれるとコピペでうつせるからうれしいです...!

@mineKohacraft

チャット欄で実行するコマンド
/tickingarea add ~~~ ~~~ command
/scoreboard objectives add counterattack_time dummy
/give @s repeating_command_block
/give @s chain_command_block

コマンドブロックに書き込むコマンド
scoreboard players set @a[hasitem=[{item=shield,location=slot.weapon.offhand},{item=shield,location=slot.weapon.offhand,data=0,quantity=0}]] counterattack_time 12

tag @a[scores={counterattack_time=1..},hasitem=[{item=iron_sword,location=slot.weapon.mainhand},{item=iron_sword,location=slot.weapon.mainhand,data=0,quantity=0}]] add counterattack

execute as @a[tag=counterattack] at @s positioned ^^0.5^3 run damage @e[r=3,family=monster] 24 entity_attack entity @s

execute as @a[tag=counterattack] at @s run particle minecraft:large_explosion ^-1^2^3.5

execute as @a[tag=counterattack] at @s run particle minecraft:large_explosion ^^2^3.8

execute as @a[tag=counterattack] at @s run particle minecraft:large_explosion ^1^2^3.5

execute as @a[tag=counterattack] at @s run playsound mob.blaze.hit @a ~~~ 1 0.75

execute as @a[tag=counterattack] at @s run scoreboard players set @s counterattack_time 0

tag @a remove counterattack

scoreboard players add @a[scores={counterattack_time=1..}] counterattack_time -1

replaceitem entity @a[hasitem=[{item=shield,location=slot.weapon.offhand},{item=shield,location=slot.weapon.offhand,data=0,quantity=0}]] slot.weapon.offhand 0 shield 1

replaceitem entity @a[hasitem=[{item=iron_sword,location=slot.weapon.mainhand},{item=iron_sword,location=slot.weapon.mainhand,data=0,quantity=0}]] slot.weapon.mainhand 0 iron_sword 1