0

I am trying to update (from 1.12 to 1.13) my cannon system in which if a monster not on team "good" comes within a 4 block radius of the command block, the cannon will fire arrows. Also, if those arrows are in that same radius as well, the arrows will be teleported to the monster and damage it. I have it set up so that the cannon fires; that's not the problem. The problem is getting those airborn arrows to be teleported to the monster within that same 4 block radius. The whole idea of this system is to ensure that all arrows fired hit a target within that radius. In 1.12, the command I used was this:

/execute @e[team=!good,r=4] ~ ~ ~ tp @e[type=arrow,r=4] @e[team=!good,r=4]

I attempted to update this command by by doing this:

/execute at @e[team=!good,distance=..4] run tp @e[type=arrow,distance=..4] @e[type=arrow,distance=..4]

According to the error message, "the provided selector allows more than one position." How can I overcome this? Also, I would like the arrow to still inflict damage on impact, I am not sure teleporting arrows will still do damage or not.

  • 1. It's talking about the last selector, that selects all arrows around and you can't teleport to multiple entities anymore (it wasn't even useful before). 2. Why would you teleport an arrow to an arrow? 3. Your command is pretty easy to fix, but maybe you want something better: In 1.13 you can use just one command to always teleport the arrow a little bit in the direction of the monster, which makes it look like the arrow is chasing the mob, which looks really cool. Do you want that instead? – Fabian Röling Oct 19 '18 at 8:32
  • As long as it inflicts damage; yes, that sounds great! – user212269 Oct 20 '18 at 14:30
  • Is the only thing you want just some damage? Then you could just use the instant damage effect. – Fabian Röling Oct 20 '18 at 19:17
  • No, then that would eliminate the purpose of the cannon. I should specify: As long as your method described above (arrow chasing mob) will deal arrow damage to that monster, I am happy with that solution. – user212269 Oct 20 '18 at 21:10
  • In theory it should, but the arrows behave very weirdly, I don't know why. But of course the simple teleport solution works. – Fabian Röling Oct 20 '18 at 22:30
0

Arrows seem to be a bit weird with their motion. In theory this should make homing arrows which chase down the nearest target:

execute as @e[type=arrow] at @s run teleport @s ^ ^ ^1 facing entity @e[type=!arrow,sort=nearest,limit=1]

But for some reason this doesn't quite work. Same with explicitly setting their motion:

execute as @e[type=arrow] store result score @s x run data get entity @s Pos[0] 10
execute as @e[type=arrow] store result score @s y run data get entity @s Pos[1] 10
execute as @e[type=arrow] store result score @s z run data get entity @s Pos[2] 10
execute at @e[type=arrow] as @e[type=!arrow,sort=nearest,limit=1] at @s store result score @s x run data get entity @s Pos[0] 10
execute at @e[type=arrow] as @e[type=!arrow,sort=nearest,limit=1] at @s store result score @s y run data get entity @s Pos[1] 10
execute at @e[type=arrow] as @e[type=!arrow,sort=nearest,limit=1] at @s store result score @s z run data get entity @s Pos[2] 10
execute as @e[type=arrow] at @s run scoreboard players operation @s x -= @e[type=!arrow,sort=nearest,limit=1] x
execute as @e[type=arrow] at @s run scoreboard players operation @s y -= @e[type=!arrow,sort=nearest,limit=1] y
execute as @e[type=arrow] at @s run scoreboard players operation @s z -= @e[type=!arrow,sort=nearest,limit=1] z
execute as @e[type=arrow] store result entity @s Motion[0] double -0.01 run scoreboard players get @s x
execute as @e[type=arrow] store result entity @s Motion[1] double -0.01 run scoreboard players get @s y
execute as @e[type=arrow] store result entity @s Motion[2] double -0.01 run scoreboard players get @s z

But for some reason these seem to work differently with arrows. I tested it with chickens and it works great. So these are two solutions that should work, but don't, I don't know why.


So here is the answer to your original question instead: Just teleporting arrows to other entities:

execute as @e[type=arrow] at @s run tp @s @e[type=!arrow,sort=nearest,limit=1]

To limit the radius, add ,distance=..<number> to the target selector.

  • My most disappointing gamingSE answer so far… :( – Fabian Röling Oct 20 '18 at 21:07
  • I've tried many things since then, the best was execute as @e[type=arrow] at @s facing entity @e[type=!arrow,type=!player,sort=nearest,limit=1] eyes run teleport @s ^ ^ ^1, which sometimes hits the zombie, but usually not. – Fabian Röling Oct 20 '18 at 23:57
  • Your most recent method (execute as @e[type=arrow] at @s facing entity @e[type=!arrow,type=!player,sort=nearest,limit=1] eyes run teleport @s ^ ^ ^1) has worked the best so far. It actually works better than your methods in the answer. – user212269 Oct 21 '18 at 19:59
  • The last command in the question teleports the arrow directly to the target, so that should work reliably, just without animation. – Fabian Röling Oct 21 '18 at 22:26
-2

/tp @e [type=arrow, r=4] (person you want to hit). If it doesn't work I'm sorry I usually work with Win 10. And PLEASE Don't use the () in your command. It won't work anymore. :-|

  • It doesn't work period... That's 1.12 – user212269 Oct 28 '18 at 17:12

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.