How to launch an entity in the direction it's looking in one function - IN UNDER 2 MINUTES
Hello there! Today i will quickly explain how to launch an entity in the direction it's looking with a single function.
=============================
The Commads:
execute store result score @s x_pos1 run data get entity @s Pos[0] 1000
execute store result score @s y_pos1 run data get entity @s Pos[1] 1000
execute store result score @s z_pos1 run data get entity @s Pos[2] 1000
summon minecraft:armor_stand ^ ^ ^1 {ShowArms:1b,Invisible:1b,Marker:1b,Tags:["EntityLaunch"]}
execute store result score @s x_pos2 run data get entity @e[tag=EntityLaunch,limit=1] Pos[0] 1000
execute store result score @s y_pos2 run data get entity @e[tag=EntityLaunch,limit=1] Pos[1] 1000
execute store result score @s z_pos2 run data get entity @e[tag=EntityLaunch,limit=1] Pos[2] 1000
kill @e[tag=EntityLaunch]
scoreboard players operation @s x_pos2 -= @s x_pos1
scoreboard players operation @s y_pos2 -= @s y_pos1
scoreboard players operation @s z_pos2 -= @s z_pos1
scoreboard players set @s y_pos2 700
execute store result entity @s Motion[0] double 0.001 run scoreboard players get @s x_pos2
execute store result entity @s Motion[1] double 0.001 run scoreboard players get @s y_pos2
execute store result entity @s Motion[2] double 0.001 run scoreboard players get @s z_pos2
=============================
Below you can find the explanation.
/execute store result score @s x_pos1 run data get entity @s Pos[0] 1000
/execute store result score @s y_pos1 run data get entity @s Pos[1] 1000
/execute store result score @s z_pos1 run data get entity @s Pos[2] 1000
What these commands do (i'll break it in two parts):
| "execute store result score @s x_pos1..."
-Makes an entity change some scoreboard value to so something we would get, like health, XP, an attribute or something else that is a number;
| "...run data get entity @s Pos[0] 1000"
-In this part we run some command that gets some vaule. The '[0]' defines what part of an nbt tag to get (for example, tag Pos is split in 3 values: x, y, and z, like [14.543, 67.436, -43.875]). The first part is 0. And 1000 is the scale, which is by how much the value is multiplied, I will explain later why is this important.
/summon minecraft:armor_stand ^ ^ ^1 {ShowArms:1b,Invisible:1b,Marker:1b,Tags:["EntityLaunch"]}
-Summons an armor stand 1 block ahead of the entity that is invisible and has marker tag, which makes the armor stand have bassicly no hitbox. Also gives the armor stand "EntityLaunch" tag (you can use anything else though), with which we would detect this specific armor stand.
/execute store result score @s x_pos2 run data get entity @e[tag=EntityLaunch,limit=1] Pos[0] 1000
/execute store result score @s y_pos2 run data get entity @e[tag=EntityLaunch,limit=1] Pos[1] 1000
/execute store result score @s z_pos2 run data get entity /@e[tag=EntityLaunch,limit=1] Pos[2] 1000
-Makes the entity we want to launch store the armor stand's position.
/kill @e[tag=EntityLaunch]
-Removes the armor stand.
/scoreboard players operation @s x_pos2 -= @s x_pos1
/scoreboard players operation @s y_pos2 -= @s y_pos1
/scoreboard players operation @s z_pos2 -= @s z_pos1
-Makes the entity we want to launch subtract the 2nd scoreboard value (x/y/z_pos1) the 1st one (x/y/z_pos2), which we will use then to launch the entity.
/execute store result entity @s Motion[0] double 0.001 run scoreboard players get @s x_pos2
/execute store result entity @s Motion[1] double 0.001 run scoreboard players get @s y_pos2
/execute store result entity @s Motion[2] double 0.001 run scoreboard players get @s z_pos2
I'll break down in two parts:
"execute store result entity @s Motion[0]/[1]/[2] double 0.001..." - makes the entity set it's Motion nbt tag to a value we can get which would change the entity's motion vector, at a scale of 0.001 (divided by 1000).
Now why is this important: We can't store intenger values in scoreboards. For example, an entity's X position might be 1.464, but it will only store 1.
However if we will multiply it by 1000, we will get 1464, and if we will divide it by 1000 later - we will get that fraction (1.464) back.
"...run scoreboard players get @s z_pos2"
-Gets some value after "run".
===========================
Ignore everything below...
britpop, pop, chamber, chanson, chorus, classical, solo, darkwave, electronic, opera, vocal, terror, lofi, lo, fi, radio, ost, metal, heavy, dark, upbeat, happy, sad, chord, theory, lesson, guide, cakewalk, fl, studio, reaper, logic, pro, reason, sonar, tools, cubase, live, abelton, how, to, write, make, bitwig, studio, musician, artist, minecraft, lets, play, modded, map, rhythm, block, mod, hypixel, mineplex, skyblock, rlcraft, dawncraft, skywars, bedwars, end, nether, build, castle, progression, mine, craft, cube, man, mineman, pvp, data, pack, datapack, command, block, function,
#minecraft #commandblock #datapacks
Other Videos By ♫ SakePlayS ♫
Other Statistics
The Entity Statistics For ♫ SakePlayS ♫
There are 43 views in 1 video for The Entity. Less than an hour worth of The Entity videos were uploaded to his channel, making up less than 0.15% of the total overall content on ♫ SakePlayS ♫'s YouTube channel.