#Spawns instantly flying fireballs at a specific point
1 messages · Page 1 of 1 (latest)
1.21.11
What's the condition?
wait a second
I have already written down the condition, briefly , when I use a carrot on a fishing rod, while holding a honeycomb in offhand, then spawn should occur
It will be a multi-command process
This should work in your datpack!
scoreboard objectives add crod_used used:carrot_on_a_stick
scoreboard objectives add fball dummy
execute as @a[scores={crod_used=1..}] if entity @s[nbt={Inventory:[{Slot:-106b,id:"minecraft:honeycomb"}]}] run function fball:launch
scoreboard players set @a[scores={crod_used=1..}] crod_used 0
execute anchored eyes run summon marker ^ ^ ^100 {Tags:["fball_target"]}
summon marker ~ ~50 ~ {Tags:["fball_origin"]}
execute store result score #tx fball run data get entity @e[tag=fball_target,limit=1] Pos[0] 100
execute store result score #ty fball run data get entity @e[tag=fball_target,limit=1] Pos[1] 100
execute store result score #tz fball run data get entity @e[tag=fball_target,limit=1] Pos[2] 100
execute store result score #ox fball run data get entity @e[tag=fball_origin,limit=1] Pos[0] 100
execute store result score #oy fball run data get entity @e[tag=fball_origin,limit=1] Pos[1] 100
execute store result score #oz fball run data get entity @e[tag=fball_origin,limit=1] Pos[2] 100
scoreboard players operation #dx fball = #tx fball
scoreboard players operation #dx fball -= #ox fball
scoreboard players operation #dy fball = #ty fball
scoreboard players operation #dy fball -= #oy fball
scoreboard players operation #dz fball = #tz fball
scoreboard players operation #dz fball -= #oz fball
execute store result storage fball:data dx double 0.0001 run scoreboard players get #dx fball
execute store result storage fball:data dy double 0.0001 run scoreboard players get #dy fball
execute store result storage fball:data dz double 0.0001 run scoreboard players get #dz fball
execute at @e[tag=fball_origin,limit=1] run function fball:summon_fireball with storage fball:data
kill @e[tag=fball_target]
kill @e[tag=fball_origin]
$summon fireball ~ ~ ~ {direction:[$(dx)d,$(dy)d,$(dz)d],ExplosionPower:1} ```
That is some old and very deprecated code you use there
You can simplify that by a lot and make it more performant too
give me a sec
Ok
I just went with what works
start.mcfunction (has to be executed as and at the player)
[30m# code for your carrot on a stick reset
# ...
[35mexecute [34munless items entity [36m@s [0mweapon.offhand honeycomb [34mrun [35mreturn [34mfail
[35mexecute [34manchored eyes run [35mfunction [33mnamespace:mark_target_pos
[35mexecute [34mpositioned [32m~ ~50 ~ [34msummon [0mmarker [34mrun [35mfunction [33mnamespace:setup_fireball_motion
[35mexecute [34mpositioned [32m~ ~50 ~ [34msummon [0mfireball [34mrun [35mdata [34mmodify entity [36m@s [0mMotion [34mset from entity [36m@e[33m[[37mtype[34m=[32mmarker[34m,[37mtag[34m=[32mfireball_setup[34m,[37mtag[34m=[32mfireball_motion[34m,[37mlimit[34m=[32m1[33m] [0mPos
[35mkill [36m@e[33m[[37mtype[34m=[32mmarker[34m,[37mtag[34m=[32mfireball_setup[33m]
mark_target_pos.mcfunction
[35mexecute [34munless block [32m~ ~ ~ [0mair [34mrun [35msummon [0mmarker [32m~ ~ ~ [33m{[37mTags[34m:[35m[[32m"fireball_setup"[34m, [32m"target_pos"[35m][33m}
[35mexecute [34mif block [32m~ ~ ~ [0mair [34mpositioned [32m^ ^ ^0.2 [34mrun [35mfunction [33mnamespace:mark_target_pos
setup_fireball_motion.mcfunction
[35mtag [36m@s [34madd [0mfireball_setup
[35mtag [36m@s [34madd [0mfireball_motion
[35mexecute [34mat [36m@s [34mrun [0mrotate [36m@s [34mfacing entity [36m@e[33m[[37mtype[34m=[32mmarker[34m,[37mtag[34m=[32mfireball_setup[34m,[37mtag[34m=[32mtarget_pos[34m,[37mlimit[34m=[32m1[33m]
[35mexecute [34mpositioned [32m0 0 0 [34mrun [35mtp [36m@s [32m^ ^ ^1
Thanks for the help, but the fireballs are off-target. I might've messed up and put the code in the wrong place. Can you help me fix this, please
I can look at it once I get back home (tbh, I didn't fully test the code I just wrote it and pressed send).
No problem, write if you need any information about my code.