⛄雪球传送菜单完整版(Java 版 1.19+,命令方块套装)
功能:手持不同雪球(靠自定义名字区分)右键,传送到对应地点
前置:全部命令方块保持开启,需要红石的就放红石 / 红石块
原理:hasitem 检测主手物品名称,匹配成功传送
你只需要先去各个地点,记下坐标替换下面 x y z
第一步:先准备 3 个命名雪球(聊天框输入,拿在手上)
plaintext


主城雪球
/give @s snowball[minecraft:custom_name='{"text":"返回主城","color":"green"}']
副本雪球
/give @s snowball[minecraft:custom_name='{"text":"前往副本","color":"red"}']
商店雪球
/give @s snowball[minecraft:custom_name='{"text":"商店","color":"aqua"}']

第二步:3 个【循环、无条件、保持开启】命令方块
依次放入下面三条,分别改后面的坐标
mcfunction


1. 返回主城
execute as @a at @s if item entity @s weapon.mainhand snowball[minecraft:custom_name='{"text":"返回主城","color":"green"}'] run tp @s 0 64 0
2. 前往副本
execute as @a at @s if item entity @s weapon.mainhand snowball[minecraft:custom_name='{"text":"前往副本","color":"red"}'] run tp @s 100 64 200
3. 商店
execute as @a at @s if item entity @s weapon.mainhand snowball[minecraft:custom_name='{"text":"商店","color":"aqua"}'] run tp @s -50 64 100

✅ 修改方法:把 0 64 0 换成你站在目标地点按 F3 看到的 X Y Z
可选升级:传送后播放提示音效 + 弹出标题
套在同一条 execute 里(用run多段,Java1.20.2 + 支持链式 run)
示例(主城完整版一条):
mcfunction


execute as @a at @s if item entity @s weapon.mainhand snowball[minecraft:custom_name='{"text":"返回主城","color":"green"}'] run (tp @s 0 64 0; title @s title {"text":"回到主城","color":"green"}; playsound entity.player.levelup @s)

🧩 拓展:增加一个返回出生点雪球
plaintext


/give @s snowball[minecraft:custom_name='{"text":"回到出生点","color":"yellow"}']

对应循环 CB:
mcfunction


execute as @a at @s if item entity @s weapon.mainhand snowball[minecraft:custom_name='{"text":"回到出生点","color":"yellow"}'] run tp @s @s world_spawn

⚠️小问题修复
• 一直拿着雪球会反复传送:
方案 A:传送后清除雪球(一次性传送球,推荐)
mcfunction


execute as @a at @s if item entity @s weapon.mainhand snowball[minecraft:custom_name='{"text":"返回主城","color":"green"}'] run (tp @s 0 64 0; clear @s snowball[minecraft:custom_name='{"text":"返回主城","color":"green"}'])

用这个版本,雪球用一次消失,不会疯狂瞬移
📌 推荐最终成品(一次性消耗雪球版本,复制即用,改坐标)
mcfunction


返回主城(消耗雪球)
execute as @a at @s if item entity @s weapon.mainhand snowball[minecraft:custom_name='{"text":"返回主城","color":"green"}'] run (tp @s 0 64 0; clear @s snowball[minecraft:custom_name='{"text":"返回主城","color":"green"}']; title @s title {"text":"✅主城","color":"green"})
前往副本(消耗雪球)
execute as @a at @s if item entity @s weapon.mainhand snowball[minecraft:custom_name='{"text":"前往副本","color":"red"}'] run (tp @s 100 64 200; clear @s snowball[minecraft:custom_name='{"text":"前往副本","color":"red"}']; title @s title {"text":"⚠️副本","color":"red"})
商店(消耗雪球)
execute as @a at @s if item entity @s weapon.mainhand snowball[minecraft:custom_name='{"text":"商店","color":"aqua"}'] run (tp @s -50 6