Skip to content

Instantly share code, notes, and snippets.

@VityaSchel
Last active July 30, 2020 21:24
Show Gist options
  • Save VityaSchel/56f177eb7e90f79c1f84dfca59eda270 to your computer and use it in GitHub Desktop.
Save VityaSchel/56f177eb7e90f79c1f84dfca59eda270 to your computer and use it in GitHub Desktop.
Check my video with demonstration! https://youtu.be/Rh748hTNgoo
So I suppose I did a very stupid mistake somewhere in 4-6,
but I'm really tired to seek for it and just skipping 4 and
6 steps isn't help, if someone found what's wrong with my
code, pls write somewhere idk I want to sleep
You may use chain command blocks, stack all them together
or use repeaters like me. Important thing to remember is that
they must be executed followed by each other like here.
0. Create objectives with dummy or trigger type (this way
these objectives won't be affected by game events and can
only be changed by player's command) and armor stand (or any
mob that will be throwing fireballs) with specified tag
/scoreboard objectives add x dummy
/scoreboard objectives add y dummy
/scoreboard objectives add z dummy
/scoreboard objectives add x2 dummy
/scoreboard objectives add y2 dummy
/scoreboard objectives add z2 dummy
/scoreboard objectives add x3 dummy
/scoreboard objectives add y3 dummy
/scoreboard objectives add z3 dummy
/summon minecraft:armor_stand ~ ~ ~ {NoGravity:1,Tags:["test_armorstand"]}
1. Put coordinates of player into scoreboards
/execute store result score @p x run data get entity @p Pos[0]
/execute store result score @p y run data get entity @p Pos[1]
/execute store result score @p z run data get entity @p Pos[2]
Pos - array in data of any entity, it contains double values
0 means X, 1 means Y, 2 means Z
2. Put coordinates of mob into scoreboards
/execute store result score @p x2 run data get entity @e[tag=test_armorstand,limit=1] Pos[0]
/execute store result score @p y2 run data get entity @e[tag=test_armorstand,limit=1] Pos[1]
/execute store result score @p z2 run data get entity @e[tag=test_armorstand,limit=1] Pos[2]
limit=1 is needed, so command data will find only 1 enemy,
which is armor stand
3. Extract 2nd coordinates from 1st coordinates
/scoreboard players operation @p x2 -= @p x
/scoreboard players operation @p y2 -= @p y
/scoreboard players operation @p z2 -= @p z
4. Set x, y, z to 0
/scoreboard players set @p x3 0
/scoreboard players set @p y3 0
/scoreboard players set @p z3 0
5. Extract x2, y2, z2 from 0 to invert vector
/scoreboard players operation @p x3 -= @p x2
/scoreboard players operation @p y3 -= @p y2
/scoreboard players operation @p z3 -= @p z2
6. Put mob's coordinates to x, y, z
/execute store result score @p x run data get entity @e[tag=test_armorstand,limit=1] Pos[0]
/execute store result score @p y run data get entity @e[tag=test_armorstand,limit=1] Pos[1]
/execute store result score @p z run data get entity @e[tag=test_armorstand,limit=1] Pos[2]
7. Spawn fireball
/summon minecraft:dragon_fireball ~ ~10 ~ {Tags:["fball"]}
Spawn in air to prevent it from explosion
8. Set position of fireball to mob's position
/execute store result entity @e[tag=fball,limit=1] Pos[0] double 1 run scoreboard players get @p x
/execute store result entity @e[tag=fball,limit=1] Pos[1] double 1 run scoreboard players get @p y
/execute store result entity @e[tag=fball,limit=1] Pos[2] double 1 run scoreboard players get @p z
9. (Optional) Divide results to slow down fireball
/scoreboard objectives add divideOperation dummy
/scoreboard players set @p divideOperation 10
/scoreboard players operation @p x3 /= @p divideOperation
/scoreboard players operation @p y3 /= @p divideOperation
/scoreboard players operation @p z3 /= @p divideOperation
Minecraft does not support operations (except adding) with
pure numbers, so we must add another objective and set it.
10. Set vector to fireball
/execute store result entity @e[tag=fball,limit=1] power[0] double 1 run scoreboard players get @p x3
/execute store result entity @e[tag=fball,limit=1] power[1] double 1 run scoreboard players get @p y3
/execute store result entity @e[tag=fball,limit=1] power[2] double 1 run scoreboard players get @p z3
power is nbt tag which is used to give direction to fireball
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment