GUI传送

By 洪荒太初    2019/02/12

大家好,我是洪荒太初,今天第一次发帖非常开心2333

今天给大家带来的是GUI传送系统!根据july老哥的tp系统我产生出GUI进行tp的想法,如图:

我的世界GUI传送 我的世界GUI传送

原理

通过三个变量控制三个坐标轴键入模块的开启与关闭,开启的模块进行数字整合并暂时保存,期间可以进行删除,正负切换,归零等操作,三个坐标轴键入完后按确定会召唤一个无重力的名为tp的aec,之后把玩家键入的三个数字依次存入这个aec的Pos[0],Pos[1],Pos[2]这三项中,最后把玩家tp到这个aec整个流程就结束了!

甘小蔗温馨补充:关于坐标轴键入其实就是在玩家通过clickEvent trigger设置完自己temp_0记分项之后,给temp_1乘以10,再加上temp_0的分数,就可以实现位操作了;删除则是给temp_1除以10。

代码

初始化:

  1. /scoreboard objectives add -1 dummy
  2. /scoreboard players set -1 -1 -1
  3. /scoreboard objectives add tp_value_set trigger
  4. /scoreboard objectives add scanf_tp trigger
  5. /scoreboard objectives add reverse trigger
  6. /scoreboard objectives add x_tp trigger
  7. /scoreboard objectives add y_tp trigger
  8. /scoreboard objectives add z_tp trigger
  9. /scoreboard objectives add delete_tp trigger
  10. /scoreboard objectives add tp_clear trigger
  11. /scoreboard objectives add tp_true trigger
  12. /scoreboard objectives add 10 dummy
  13. /scoreboard players set 10 10 10
  14. /scoreboard objectives add y_value dummy
  15. /scoreboard objectives add z_value dummy
  16. /scoreboard objectives add x_value dummy
  17. /give @p minecraft:written_book{title:"多功能书",author:"洪荒太初",pages:["[{\"text\":\"点击此处设置传送\",\"color\":\"green\",\"underlined\":true,\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/trigger scanf_tp set 1\"}}]"]} 1

外显&重置:

  1. execute as @a[tag=x_tp] run title @s actionbar ["",{"text":"x_pos:","color":"green"},{"score":{"name":"@s","objective":"x_value"},"color":"gold"}]
  2. execute as @a[tag=y_tp] run title @s actionbar ["",{"text":"y_pos:","color":"green"},{"score":{"name":"@s","objective":"y_value"},"color":"gold"}]
  3. execute as @a[tag=z_tp] run title @s actionbar ["",{"text":"z_pos:","color":"green"},{"score":{"name":"@s","objective":"z_value"},"color":"gold"}]
  4. title @a times 0 2 0
  5. scoreboard players set @a[scores={tp_clear=1..1}] x_value 0
  6. scoreboard players set @a[scores={tp_clear=1..1}] y_value 0
  7. scoreboard players set @a[scores={tp_clear=1..1}] z_value 0
  8. execute as @a[scores={tp_clear=1..1}] run kill @e[type=minecraft:area_effect_cloud,name=tp,limit=1,sort=nearest]
  9. tag @a[scores={tp_clear=1..1}] remove x_tp
  10. tag @a[scores={tp_clear=1..1}] remove y_tp
  11. tag @a[scores={tp_clear=1..1}] remove x_tp
  12. scoreboard players set @a[scores={tp_clear=1..1}] tp_clear 0

GUI响应&trigger授权:

  1. tellraw @a[scores={scanf_tp=1..1}] ["",{"text":"[传送系统]\n","color":"green"},{"text":"【1】","color":"gold","clickEvent":{"action":"run_command","value":"/trigger tp_value_set set 1"}},{"text":"【2】","color":"gold","clickEvent":{"action":"run_command","value":"/trigger tp_value_set set 2"}},{"text":"【3】\n","color":"gold","clickEvent":{"action":"run_command","value":"/trigger tp_value_set set 3"}},{"text":"【4】","color":"gold","clickEvent":{"action":"run_command","value":"/trigger tp_value_set set 4"}},{"text":"【5】","color":"gold","clickEvent":{"action":"run_command","value":"/trigger tp_value_set set 5"}},{"text":"【6】\n","color":"gold","clickEvent":{"action":"run_command","value":"/trigger tp_value_set set 6"}},{"text":"【7】","color":"gold","clickEvent":{"action":"run_command","value":"/trigger tp_value_set set 7"}},{"text":"【8】","color":"gold","clickEvent":{"action":"run_command","value":"/trigger tp_value_set set 8"}},{"text":"【9】","color":"gold","clickEvent":{"action":"run_command","value":"/trigger tp_value_set set 9"}},{"text":"【0】\n","color":"gold","clickEvent":{"action":"run_command","value":"/trigger tp_value_set set 0"}},{"text":" x ","color":"gold","clickEvent":{"action":"run_command","value":"/trigger x_tp set 1"}},{"text":" y ","color":"gold","clickEvent":{"action":"run_command","value":"/trigger y_tp set 1"}},{"text":" z \n","color":"gold","clickEvent":{"action":"run_command","value":"/trigger z_tp set 1"}},{"text":"【←】","color":"gold","clickEvent":{"action":"run_command","value":"/trigger delete_tp set 1"}},{"text":"【归零】","color":"gold","clickEvent":{"action":"run_command","value":"/trigger tp_clear set 1"}},{"text":"【确定】","color":"gold","clickEvent":{"action":"run_command","value":"/trigger tp_true set 1"}},{"text":"【正负反转】","color":"green","clickEvent":{"action":"run_command","value":"/trigger reverse set 1"}}]
  2. scoreboard players set @a[scores={scanf_tp=1..1}] scanf_tp 0 (条件制约)
  3. scoreboard players set @a[scores={scanf_tp=1..1}] tp_clear 1
  4. scoreboard players enable @a delete_tp
  5. scoreboard players enable @a scanf_tp
  6. scoreboard players enable @a tp_clear
  7. scoreboard players enable @a tp_value_set
  8. scoreboard players enable @a x_tp
  9. scoreboard players enable @a y_tp
  10. scoreboard players enable @a z_tp
  11. scoreboard players enable @a reverse
  12. scoreboard players enable @a tp_true

键入线程控制:

  1. execute as @a[scores={x_tp=1..1}] run tag @s add x_tp
  2. execute as @a[scores={x_tp=1..1}] run tag @s remove y_tp
  3. execute as @a[scores={x_tp=1..1}] run tag @s remove z_tp
  4. scoreboard players set @a[scores={x_tp=1..1}] x_tp 0
  5. execute as @a[scores={y_tp=1..1}] run tag @s add y_tp
  6. execute as @a[scores={y_tp=1..1}] run tag @s remove x_tp
  7. execute as @a[scores={y_tp=1..1}] run tag @s remove z_tp
  8. scoreboard players set @a[scores={y_tp=1..1}] y_tp 0
  9. execute as @a[scores={z_tp=1..1}] run tag @s add z_tp
  10. execute as @a[scores={z_tp=1..1}] run tag @s remove y_tp
  11. execute as @a[scores={z_tp=1..1}] run tag @s remove x_tp
  12. scoreboard players set @a[scores={z_tp=1..1}] z_tp 0

x轴数值整合:

  1. execute as @a[scores={tp_value_set=-2147483647..},tag=x_tp] run scoreboard players operation @s x_value *= 10 10
  2. execute as @a[tag=x_tp,scores={tp_value_set=-2147483647..}] run scoreboard players operation @s x_value += @s tp_value_set
  3. scoreboard players set @a[tag=x_tp,scores={tp_value_set=-2147483647..}] tp_value_set -2147483648
  4. scoreboard players operation @a[scores={delete_tp=1..1},tag=x_tp] x_value /= 10 10
  5. scoreboard players set @a[scores={delete_tp=1..1}] delete_tp 0
  6. scoreboard players operation @a[scores={reverse=1..1},tag=x_tp] x_value *= -1 -1
  7. scoreboard players set @a[scores={reverse=1..1},tag=x_tp] reverse 0

y轴数值整合:

  1. execute as @a[tag=y_tp,scores={tp_value_set=-2147483647..}] run scoreboard players operation @s y_value *= 10 10 execute as @a[tag=y_tp,scores={tp_value_set=-2147483647..}] run scoreboard players operation @s y_value += @s tp_value_set /scoreboard players set @a[tag=y_tp,scores={tp_value_set=-2147483647..}] tp_value_set -2147483648 scoreboard players operation @a[scores={delete_tp=1..1}] y_value /= 10 10 scoreboard players operation @a[scores={reverse=1..1},tag=y_tp] y_value *= -1 -1 scoreboard players set @a[scores={reverse=1..1},tag=y_tp] reverse 0

z轴数值整合:

  1. execute as @a[tag=z_tp,scores={tp_value_set=-2147483647..}] run scoreboard players operation @s z_value *= 10 10
  2. execute as @a[tag=z_tp,scores={tp_value_set=-2147483647..}] run scoreboard players operation @s z_value += @s tp_value_set
  3. scoreboard players set @a[tag=z_tp,scores={tp_value_set=-2147483647..}] tp_value_set -2147483648
  4. scoreboard players operation @a[scores={delete_tp=1..1}] z_value /= 10 10
  5. scoreboard players operation @a[scores={reverse=1..1},tag=z_tp] z_value *= -1 -1
  6. scoreboard players set @a[scores={reverse=1..1},tag=z_tp] reverse 0

自动报点&维度:

  1. execute as @a[nbt={Dimension:0},scores={dis_pos=1..1}] at @s run tellraw @a ["",{"selector":"@s","color":"red"},{"text":"的x坐标为\n","color":"green"},{"nbt":"Pos[0]","entity":"@s","color":"yellow"},{"text":"\n"},{"text":"y坐标为\n","color":"green"},{"nbt":"Pos[1]","entity":"@s","color":"yellow"},{"text":"\n"},{"text":"z坐标为\n","color":"green"},{"nbt":"Pos[2]","entity":"@s","color":"yellow"},{"text":"\n"},{"text":"维度为\n","color":"green"},{"text":"主世界","color":"yellow"}]
  2. execute as @a[nbt={Dimension:1},scores={dis_pos=1..1}] at @s run tellraw @a ["",{"selector":"@s","color":"red"},{"text":"的x坐标为\n","color":"green"},{"nbt":"Pos[0]","entity":"@s","color":"yellow"},{"text":"\n"},{"text":"y坐标为\n","color":"green"},{"nbt":"Pos[1]","entity":"@s","color":"yellow"},{"text":"\n"},{"text":"z坐标为\n","color":"green"},{"nbt":"Pos[2]","entity":"@s","color":"yellow"},{"text":"\n"},{"text":"维度为\n","color":"green"},{"text":"末地","color":"yellow"}]
  3. execute as @a[nbt={Dimension:-1},scores={dis_pos=1..1}] at @s run tellraw @a ["",{"selector":"@s","color":"red"},{"text":"的x坐标为\n","color":"green"},{"nbt":"Pos[0]","entity":"@s","color":"yellow"},{"text":"\n"},{"text":"y坐标为\n","color":"green"},{"nbt":"Pos[1]","entity":"@s","color":"yellow"},{"text":"\n"},{"text":"z坐标为\n","color":"green"},{"nbt":"Pos[2]","entity":"@s","color":"yellow"},{"text":"\n"},{"text":"维度为\n","color":"green"},{"text":"地狱","color":"yellow"}]
  4. scoreboard players set @a[scores={dis_pos=1..1}] dis_pos 0

最终执行:

  1. execute at @a[scores={tp_true=1..1}] run summon minecraft:area_effect_cloud ~ ~ ~ {CustomName:"{\"text\":\"tp\"}",CustomNameVisible:false,NoGravity:true,CanPickUpLoot:false,Duration:2147483647,Radius:0f,Particle:"mobSpell"}
  2. execute as @a[scores={tp_true=1..1}] store result entity @e[type=minecraft:area_effect_cloud,limit=1,sort=nearest,name=tp] Pos[0] double 1 run scoreboard players get @s x_value
  3. execute as @a[scores={tp_true=1..1}] store result entity @e[type=minecraft:area_effect_cloud,limit=1,sort=nearest,name=tp] Pos[1] double 1 run scoreboard players get @s y_value
  4. execute as @a[scores={tp_true=1..1}] store result entity @e[type=minecraft:area_effect_cloud,limit=1,sort=nearest,name=tp] Pos[2] double 1 run scoreboard players get @s z_value
  5. tp @a[scores={tp_true=1..1}] @e[type=minecraft:area_effect_cloud,limit=1,sort=nearest,name=tp]
  6. execute as @a[scores={tp_true=1..1}] run kill @e[type=minecraft:area_effect_cloud,limit=1,sort=nearest,name=tp]
  7. scoreboard players set @a[scores={tp_true=1..1}] tp_true 0


NBT:20190212000.nbt

  • 1.13+NBT文件使用方法 - 桌面右击Minecraft启动器->属性->打开文件夹(位置)->.minecraft->saves->(所需要加入的NBT的存档)->generated->minecraft->structures->右键粘贴->进入游戏输入give @p structure_block->切换成加载模式->点两次加载即可




LOADING | 此框架正在加载中
QQ群:771363745