初期値に戻るアイテムについて
動画用に初期地に戻るアイテムを作成したので備忘程度のまとめ
①アイテム使用の検知の確認
・以下の参考動画を元にアイテムを使用可能にする
・今回はあまり使用されないであろう「花火の星」を対象にしました。
・見た目はリカバリーコンパス ミニゲームや企画物ではあまり作る機会がないもの
・動画ではコマンドブロックだがデータパックで使用できるように変更
参考動画:https://www.youtube.com/watch?v=fuMsF6o9mRU&t=97s
クラフターズコロニーにもよくデータパックとか投稿されている方です
②戻る位置の設定(functionで一括設定)
・戻る位置設定用の防具立て削除(以前設定した防具立て削除)
※戻る位置を1つに固定するため、誤って設定した場合も再度設定すれば利用可能にするため
kill @e[tag=tp_pos]
・①を参考にアイテム使用の検知をスコアボードに追加
scoreboard objectives add res_tp minecraft.used:minecraft.firework_star
・戻るアイテムの配布
give @a minecraft:firework_star[minecraft:consumable={consume_seconds:0,animation:”none”,sound:”minecraft:entity.enderman.teleport”,has_consume_particles:false},minecraft:item_model=recovery_compass,minecraft:item_name=”初期地にもどる”]
・戻る位置設定用の防具立て設置
summon armor_stand ~ ~ ~ {NoGravity:1b,Marker:1b,Invisible:1b,Tags:[“tp_pos”]}
・戻る用防具たてチャンク強制読み込み追加
forceload add ~ ~
③にアイテム使用の検知時の挙動を追加(function化)
・①の動画を参考にアイテムを再配布
item replace entity @a[scores={res_tp=1..}] weapon with minecraft:firework_star[minecraft:consumable={consume_seconds:0,animation:”none”,sound:”minecraft:entity.enderman.teleport”,has_consume_particles:false},minecraft:item_model=recovery_compass,minecraft:item_name=”初期地にもどる”]
・配置した防具立てにテレポート
execute at @a[scores={res_tp=1..}] as @a[scores={res_tp=1..}] at @s run tp @e[tag=tp_pos,limit=1]
・スコアボードリセット
scoreboard players reset @a res_tp
④tickごとでアイテム検知するように設定
・tick.jsonから呼び出すmcfunctionに以下のコマンドを追加
executeas@a[scores={res_tp=1..}] at @s run function <@③で作成したfunctionを指定>
実際は動画用に汎用データパックを作成しているのでフラグ管理をしていて
②設定時にフラグを追加している
tick.json→汎用ファンクション→フラグがONだったら③のfunctoin呼び出しのような仕組みにしている
タイマーとかその他の仕組みを同時に利用することを想定しているため



コメント