本帖最后由 SPGoding 于 2018-8-14 12:16 编辑
刚好还没人答,之前组里 dalao 提到过,“点动成线,线动成面,面动成体”(把这三步分别称为 step_1 step_2 step_3,点-point,线-line,面-square)。
初始化
- scoreboard objectives add tmp dummy "临时"
复制代码
在玩家执行的函数里,获取两个盔甲架 X 坐标之差:$xd
- execute store result score $x1 tmp run data get entity @e[limit=1,tag=armor_stand_1] Pos[0] 1
- execute store result score $x2 tmp run data get entity @e[limit=1,tag=armor_stand_2] Pos[0] 1
- scoreboard players operation $xd tmp = $x1 tmp
- scoreboard players operation $xd tmp -= $x2 tmp
复制代码
然后在 tag=armor_stand_1 处生成“点”盔甲架
- execute at @e[tag=armor_stand_1] run summon minecraft:armor_stand ~ ~ ~ {Tags:["armor_stand_3","point","line","square"],NoGravity:1b}
复制代码
让 tag=point 执行 step_1
- execute as @e[tag=point] run scoreboard players operation @s tmp = $xd tmp
- execute as @e[tag=point] at @s run function foobar:step_1
复制代码
大致内容就是根据上面得到的 $xd 来不断移动“点”,并在原先位置放置新的盔甲架,使得点动成线。
- # foobar:step_1
- execute unless score @s tmp matches 0 run summon minecraft:armor_stand ~ ~ ~ {Tags:["armor_stand_3","line","square"],NoGravity:1b}
- execute if score @s tmp matches 1.. run teleport @s ~1 ~ ~
- execute if score @s tmp matches 1.. run scoreboard players remove @s tmp 1
- execute if score @s tmp matches ..-1 run teleport @s ~-1 ~ ~
- execute if score @s tmp matches ..-1 run scoreboard players add @s tmp 1
- execute unless score $xd tmp matches 0 run function foobar:step_1
复制代码
在玩家执行的函数里,接着获取两个盔甲架 Y 坐标之差:$yd
- execute store result score @s tmp run data get entity @e[limit=1,tag=armor_stand_1] Pos[1] 1
- execute store result score $yd tmp run data get entity @e[limit=1,tag=armor_stand_2] Pos[1] 1
- scoreboard players operation $yd tmp = $y1 tmp
- scoreboard players operation $yd tmp -= $y2 tmp
复制代码
让 tag=line 执行 step_2
- execute as @e[tag=line] run scoreboard players operation @s tmp = $yd tmp
- execute as @e[tag=line] at @s run function foobar:step_2
复制代码
大致内容就是让刚刚生成出来的“线”根据 $yd 运动为“面”
- # foobar:step_2
- execute unless score @s tmp matches 0 run summon minecraft:armor_stand ~ ~ ~ {Tags:["armor_stand_3","square"],NoGravity:1b}
- execute if score @s tmp matches 1.. run teleport @s ~ ~1 ~
- execute if score @s tmp matches 1.. run scoreboard players remove @s tmp 1
- execute if score @s tmp matches ..-1 run teleport @s ~ ~-1 ~
- execute if score @s tmp matches ..-1 run scoreboard players add @s tmp 1
- execute unless score @s tmp matches 0 run function foobar:step_2
复制代码
在玩家执行的函数里,接着获取两个盔甲架 Z 坐标之差:$zd
- execute store result score $z1 tmp run data get entity @e[limit=1,tag=armor_stand_1] Pos[2] 1
- execute store result score $z2 tmp run data get entity @e[limit=1,tag=armor_stand_2] Pos[2] 1
- scoreboard players operation $zd tmp = $z1 tmp
- scoreboard players operation $zd tmp -= $z2 tmp
复制代码
让 tag=square 执行 step_3
- execute as @e[tag=square] run scoreboard players operation @s tmp = $zd tmp
- execute as @e[tag=square] at @s run function foobar:step_3
复制代码
大致内容就是让刚刚生成出来的“面”根据 $zd 运动为“体”
- # foobar:step_3
- execute unless score @s tmp matches 0 run summon minecraft:armor_stand ~ ~ ~ {Tags:["armor_stand_3"],NoGravity:1b}
- execute if score @s tmp matches 1.. run teleport @s ~ ~ ~1
- execute if score @s tmp matches 1.. run scoreboard players remove @s tmp 1
- execute if score @s tmp matches ..-1 run teleport @s ~ ~ ~-1
- execute if score @s tmp matches ..-1 run scoreboard players add @s tmp 1
- execute unless score @s tmp matches 0 run function foobar:step_3
复制代码
最后,移除中间步骤用到的 tag
- tag @e remove point
- tag @e remove line
- tag @e remove square
复制代码
至此,五百金粒到手。