Minecraft(我的世界)中文论坛
标题: (数据包)用盔甲架绘制长方体
作者: (=°ω°)丿 时间: 2018-8-13 13:18
标题: (数据包)用盔甲架绘制长方体
本帖最后由 Teenager_Yang 于 2018-8-13 14:45 编辑
如图1,在世界内分别有任意两个盔甲架:
盔甲架1:无重力,坐标:(x1,y1,z1),tag=armor_stand_1
盔甲架2:无重力,坐标:(x2,y2,z2),tag=armor_stand_2
x1,y1,z1,x2,y2,z2 之间无任何数量关系。
要求:制作一个数据包,使得玩家运行数据包内的函数后,以这两个盔甲架为两个顶点用盔甲架(无重力,tag=armor_stand_3)绘制一个长方体(如图2,类似于用 /fill 指令根据两个坐标填充一个长方体),并简要说明原理。
版本:1.13.1 的快照版本 18w32a
emmm……其实我只是不想打字,然后看看有没有更好的方法。
召唤术:
@ruhuasiyu
@SPGoding
@pineapple_
@⊙v⊙
@pca006132
作者: SPGoding 时间: 2018-8-13 13:18
本帖最后由 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
复制代码
至此,五百金粒到手。
作者: (=°ω°)丿 时间: 2018-8-15 12:23
本帖最后由 Teenager_Yang 于 2019-2-1 15:16 编辑
我想问一下,有没有办法可以以armor_stand_1为圆心,armor_stand_2为圆上一点画圆,生成armor_stand_3。
(你只需要回答有或没有)如果有的话,我去准备一下金粒,再发一个帖子。
作者: SPGoding 时间: 2018-8-15 14:54
有是有的,从 armor_stand_1 出发,递归到 armor_stand_2 一直生成 armor_stand_3 连出一条半径,然后旋转 armor_stand_1 一圈并一直 tp 那条半径画出一个圆
我看起来像是缺金粒的人吗!
作者: pineapple_ 时间: 2018-8-17 02:26
@我了我也回复一下吧…凑巧有事过来看看冒个泡
http://www.mcbbs.net/thread-775369-1-1.html
这个之前有个类似的问题,也是fill,还是类似replace的模式呢,只不过两个坐标之间的数量关系已知,这个只需要通过记分板获取坐标一减,就能得到数量关系了,你自己看看吧,不知道和这个spg说的有没有什么太大的差别
主要就是点动成线,线动成面,面动成体
上面那家伙抢我的话就算了,还说是dalao说的
下次千万不要相信他说的鬼话