mxz_dada
7/3/2021, 11:45:34 AM
怎么召唤一个向玩家面朝向的方向飞出去的火球?
如果只是用summon fireball ~ ~ ~ {direction:[0.0,0.0,0.0]}的方法的话没法判断玩家的朝向
如果只是用summon fireball ~ ~ ~ {direction:[0.0,0.0,0.0]}的方法的话没法判断玩家的朝向
enderman_JC
7/3/2021, 11:57:11 AM
看看这样行不行(我也不确定)
execute as @a at @s run summon fireball ^1 ^ ^1 {direction:[^, ^, ^]}
execute as @a at @s run summon fireball ^1 ^ ^1 {direction:[^, ^, ^]}
mxz_dada
7/3/2021, 11:58:51 AM
enderman_JC 发表于 2021-7-3 19:57
看看这样行不行(我也不确定)
execute as @a at @s run summon fireball ^1 ^ ^1 {direction:[^, ^, ^]} ...
不行的direction:[]的中括号里必须是精确到一位的小数
enderman_JC
7/3/2021, 12:03:36 PM
mxz_dada 发表于 2021-7-3 19:58
不行的direction:[]的中括号里必须是精确到一位的小数
刚才去试了一下,估计只能先summon后tp转向(不知道别人有没有更好的办法)
Chelover_C60
7/3/2021, 11:45:35 AM
本帖最后由 Chelover_C60 于 2021-7-3 23:51 编辑
以下方法需要1.14+
原理是在世界原点处传送marker实体,并获取其坐标作为火球的direction与power
方案1:使用/forceload强加载坐标0,0点周围的四个区块,然后依次执行以下命令。需要注意的是每次只能有一个玩家发射火球,否则会出错。
复制代码
方案2:如果你会编写函数,建议使用以下方法。此方法对多人兼容良好,无需担心多人同时发射火球造成的冲突
复制代码fun1.mcfunction
复制代码fun2.mcfunction
复制代码
以下方法需要1.14+
原理是在世界原点处传送marker实体,并获取其坐标作为火球的direction与power
方案1:使用/forceload强加载坐标0,0点周围的四个区块,然后依次执行以下命令。需要注意的是每次只能有一个玩家发射火球,否则会出错。
- tag <发射火球的玩家> add summoning
- execute as @a[tag=summoning] at @s anchored eyes run summon fireball ^ ^ ^ {direction:[0d,0d,0d],Tags:["mark"]}
- summon armor_stand ~ ~ ~ {Tags:["mark"]}
- execute as @e[type=armor_stand,tag=mark] rotated as @a[tag=summoning] run tp 0.0 0.0 0.0
- execute as @e[type=armor_stand,tag=mark] at @s run tp ^ ^ ^0.1
- data modify entity @e[type=fireball,tag=mark,limit=1] power set from entity @e[type=armor_stand,limit=1,tag=mark] Pos
- execute as @e[type=armor_stand,tag=mark] at @s run tp ^ ^ ^1.5
- data modify entity @e[type=fireball,tag=mark,limit=1] direction set from entity @e[type=armor_stand,limit=1,tag=mark] Pos
- kill @e[type=armor_stand,tag=mark]
- tag @e[type=fireball,tag=mark] remove mark
- tag @a[tag=summoning] remove summoning
方案2:如果你会编写函数,建议使用以下方法。此方法对多人兼容良好,无需担心多人同时发射火球造成的冲突
- execute as <发射火球的玩家> at @s run function fun1
- tag @s add summoning
- execute anchored eyes run summon fireball ^ ^ ^ {direction:[0d,0d,0d],Tags:["mark"]}
- summon armor_stand ~ ~ ~ {Tags:["mark"]}
- execute as @e[type=armor_stand,tag=mark] run function fun2
- tag @e[type=fireball,tag=mark] remove mark
- tag @s remove summoning
- execute rotated as @a[tag=summoning] run tp 0.0 0.0 0.0
- execute at @s run tp ^ ^ ^0.1
- data modify entity @e[type=fireball,tag=mark,limit=1] power set from entity @s Pos
- execute at @s run tp ^ ^ ^1.5
- data modify entity @e[type=fireball,tag=mark,limit=1] direction set from entity @s Pos
- kill @s