Double Speed Arrows
I'm trying to make whenever an arrow is shot it will fly at double the speed without falling. The no falling part was easy, simply did execute as @e[type=arrow] run data merge entity @s {NoGravity:1}
and that did the trick.
The other part is the real problem. As I understand, I'd have to
execute as @e[type=arrow] store success entity @s Motion double
- somehow double that value
-
run data merge entity @s {Motion: (whatever I got earlier) }
on that arrow
I can store the data all right, but the problem is I am completely oblivious of how to double that, fetch, and merge value simultaneously.
I've considered creating an individual score for each values and doubling them since that's the only way I know, but I genuinely couldn't understand how the scoreboard command works.
You can use a factor to read or write NBT. And since you're dealing with floating point numbers and scoreboards can only contain integers, you should do this anyway. So you can for example multiply the value with 2000000 when reading and divide it by 1000000 when writing:
/execute as @e[type=arrow,tag=!speedy] store result score @s motion run data get entity @s Motion[0] 2000000
/execute as @e[type=arrow,tag=!speedy] store result entity @s Motion[0] double 0.000001 run scoreboard players get @s motion
/execute as @e[type=arrow,tag=!speedy] store result score @s motion run data get entity @s Motion[1] 2000000
/execute as @e[type=arrow,tag=!speedy] store result entity @s Motion[1] double 0.000001 run scoreboard players get @s motion
/execute as @e[type=arrow,tag=!speedy] store result score @s motion run data get entity @s Motion[2] 2000000
/execute as @e[type=arrow,tag=!speedy] store result entity @s Motion[2] double 0.000001 run scoreboard players get @s motion
/tag @e[type=arrow] add speedy
The tag is there so that you don't keep doubling the speed every tick. Make sure to use result
to save the value, not success
as in your question.