2

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.

1

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.

| improve this answer | |
  • It's a bit buggy, but I think I have an idea where that comes from. I think I'll get the hang of it soon. Thanks so much. – user233088 Jun 17 '19 at 14:20
  • What do you mean with "buggy"? I honestly didn't test this, I only wrote it from the wiki and memory. – Fabian Röling Jun 17 '19 at 14:36
  • The arrow sometimes (most of the times really) spazzes out while suspended from where I shot it. – user233088 Jun 17 '19 at 16:20
  • It works fine for me. Maybe you'll want to change the last command to /tag @e[type=arrow,tag=!speedy] add speedy to get less debug output. – Fabian Röling Jun 17 '19 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.