I am summoning a stationary fireball entity 2 blocks in front of the player but I need to make it travel in the direction the player looks without hitting it. I thought this might be possible to do with the new /execute store commands or with the fact that you can now raycast in Minecraft.
This is challenging, but possible. What you need to do is emulate the motion of projectile. Unfortunately i only have commands for 1.12, but you can convert it yourself
Here's my steps:
Download this zip file (it's clean, no .exe inside).
Extract and find folder cordic/compiled.
It contains the function needed for detecting player rotation.
For version 1.13, I believe I have made a relatively simple solution for your problem. What I've done is use a snowball as the projectile and then summon a fireball and have a repeating command block teleport the fireball to the snowball.
Step 1: To start, throw a snowball. Have this command repeating in a command block: [Command Block 1]
/execute as @e[type=snowball] at @s run summon small_fireball ~ ~ ~ {direction:[0.0,0.0,0.0],Tags:[Fireball]}
Note: The "tag=Fireball" is not necessary but this will ensure that any previously propelled fireballs will not be teleported to the snowball.
Other Note: If you want to create a fire trail with this fireball, use this command instead:
/execute as @e[type=snowball] at @s run summon small_fireball ~ ~ ~ {direction:[0.0,-50.0,0.0],Tags:[Fireball]}
Step 2: In a second repeating command block, paste this code to teleport the fireballs to the snowball: [Command Block 2]
/execute as @e[type=minecraft:small_fireball,tag=Fireball] run tp @e[type=minecraft:small_fireball,tag=Fireball] @e[type=minecraft:snowball,limit=1,sort=nearest]
Step 3: Place a comparator as an output of the second command block that directly touches a block with a redstone torch on the side. This will invert the output to make the next command only active when the first two are complete.
Step 4: Place a third and final command block (impulse) and paste this code to delete the fireballs after their launch: [Command Block 3]
/kill @e[type=small_fireball,tag=Fireball]
If all is set up correctly, then you should be able to throw a snowball, have small fireballs spawned and teleported to said snowball, and all delete after they are done moving. This code can be modified to have the fireballs create a fire at impact if this code is pasted into a command block (impulse) before the third command block: [Command Block 4] (Optional, but recommended)
/execute at @e[type=small_fireball,tag=Fireball] run setblock ~ ~ ~ fire
Again, this is all for version 1.13 and will not work for other versions. Let me know if you have any problems.
There's actually a solution to this that uses legit motion tags instead of teleportation workarounds, but you haven't given quite enough information about your situation to determine whether it'd work for you.
If you can answer a few questions, I should be able to provide some code that will work.
1. Are you able to add the code as a function instead of using command blocks?
2. Is it okay for the fireball to spawn closer to the player?
3. Will this be triggered by a player action such as using an item?
[noparse]data modify entity 03b34cd2-4b72-42de-a6c2-266014000ab3 Motion set value [^2, ^1, 0]
[/noparse]
But the syntax does not seem to be valid. Could you elaborate how relative coordinates should be used to make an entity/fireball/snowball/egg travel in a given direction?
Yeah, the title says it all.
I am summoning a stationary fireball entity 2 blocks in front of the player but I need to make it travel in the direction the player looks without hitting it. I thought this might be possible to do with the new /execute store commands or with the fact that you can now raycast in Minecraft.
Any help would be appreciated
This is challenging, but possible. What you need to do is emulate the motion of projectile. Unfortunately i only have commands for 1.12, but you can convert it yourself
Here's my steps:
Hope this helps (for 1.12 players like me)! Sorry, i don't know 1.13 commands.
I'm a programmer. I use C/C++, BASIC, Assembly, and Python. If i sound too technicial, that's because it's the way i think.
My Suggestions
For version 1.13, I believe I have made a relatively simple solution for your problem. What I've done is use a snowball as the projectile and then summon a fireball and have a repeating command block teleport the fireball to the snowball.
Step 1: To start, throw a snowball. Have this command repeating in a command block: [Command Block 1]
Note: The "tag=Fireball" is not necessary but this will ensure that any previously propelled fireballs will not be teleported to the snowball.
Other Note: If you want to create a fire trail with this fireball, use this command instead:
Step 2: In a second repeating command block, paste this code to teleport the fireballs to the snowball: [Command Block 2]
Step 3: Place a comparator as an output of the second command block that directly touches a block with a redstone torch on the side. This will invert the output to make the next command only active when the first two are complete.
Step 4: Place a third and final command block (impulse) and paste this code to delete the fireballs after their launch: [Command Block 3]
If all is set up correctly, then you should be able to throw a snowball, have small fireballs spawned and teleported to said snowball, and all delete after they are done moving. This code can be modified to have the fireballs create a fire at impact if this code is pasted into a command block (impulse)
before the third command block: [Command Block 4] (Optional, but recommended)Again, this is all for version 1.13 and will not work for other versions. Let me know if you have any problems.
Example setup
Did you know that 1.13 had ^ relative coordinate?
It's simpler then, just teleport the Fireball with player rotation. And then repeatedly teleport forward.
I'm a programmer. I use C/C++, BASIC, Assembly, and Python. If i sound too technicial, that's because it's the way i think.
My Suggestions
There's actually a solution to this that uses legit motion tags instead of teleportation workarounds, but you haven't given quite enough information about your situation to determine whether it'd work for you.
If you can answer a few questions, I should be able to provide some code that will work.
1. Are you able to add the code as a function instead of using command blocks?
2. Is it okay for the fireball to spawn closer to the player?
3. Will this be triggered by a player action such as using an item?
1) Yes, I actually intend to use a function to run these commands.
2) Absolutely, It really shouldn't matter how close it should be spawned.
3) This is going to be triggered with a right click of a carrot on a stick, I have managed to get this part working perfectly fine.
Hope that helped
Am i able to make the fireball explode on impact?
I tried something like that while trying to push mobs the opposite direction they were facing:
But the syntax does not seem to be valid. Could you elaborate how relative coordinates should be used to make an entity/fireball/snowball/egg travel in a given direction?
Please, support the sledgehammer tool!
I ♥ Linux. Thanks Mojang for providing a game that runs natively on that OS!