2

I'm trying to make an item that, when held, summons a fireball above the player's head. I'm using command blocks to do so, but I've run into some problems. I don't want to use any redstone because that stops working when I go too far away.

/scoreboard players add @a Fireball 1 {SelectedItem:{tag:{display:{Name:"Summon Fireball"}}}}
/execute @a[score_Fireball_min=18,score_Fireball=20] ~ ~ ~ /summon FireworksRocketEntity ~0 ~1 ~0 {Life:1,LifeTime:1,FireworksItem:{id:fireworks,Count:1,tag:{Fireworks:{Explosions:[{Type:0,Flicker:0,Trail:0,Colors:[15627776]}]}}}}
/execute @a[score_Fireball_min=20,score_Fireball=20] ~ ~ ~ /summon Fireball ~ ~2.5 ~ {direction:[0.0,0.0,0.0],ExplosionPower:1}

This part of the code works, but I want to reset the Fireball score once the fireball has been shot.

/execute @e[type=Fireball] ~ ~ ~ /scoreboard players set @p[score_Fireball_min=20,rm=3,r=4] Fireball 0

This code works when you're alone, but I play together with my friends. The problem is, that if my fireballs passes my friend, who's also summoning fireballs, his score will be reset, too. Instead, I'm trying to make a command that looks for a fireball around the player, and resets the score when the output is negative. It should be something like this;

/execute @a[score_Fireball_min=20] ~ ~ ~ /testfor @e[type=Fireball,r=3]
INV
/scoreboard players set @p Fireball 0

Note that @p in the second command has to be the same player as @a[score_Fireball_min=20] in the first command. Again, I don't want to use any redstone here, because the code will stop working when I move too far away.

Does anyone know how I can change the commands above to make them work?

1

As for your "Redstone doesn't work when far away problem", this also applies to command blocks. What you want to do is put all of your contraption in the spawn chunks or move the spawn chunks to your contraption with this command:

/setworldspawn x y z

This is because Spawn chunks are always loaded and the setworldspawn command can move worldspawn and thus also spawnchunks


Now with your problem with the fireballs behaving weird around other players in multiplayer. Maybe try giving fireballs their own score or tag which you can then test for and then make it so that only fireballs which haven't been shot yet reset the score. This is what I kinda have in mind:

/execute @a[score_Fireball_min=20] ~ ~ ~ /testfor @e[type=Fireball,r=3,tag=!notStationary]
/execute @a[score_Fireball_min=20] ~ ~ ~ /entitydata @e[type=Fireball,r=3] {tag:notStationary}
/scoreboard players set @p Fireball 0

Hopefully this explains my thoughts somewhat good as I'm not really that great with testfor and execute, feel free to call me out if what I am saying is bs tho as I am currently unable to test this as I'm not able run mc atm.

  • The problem does not occur when I only use command blocks. If I move far away, the command blocks still work, but the one that's activated by redstone does not. – Jaïr Paalman Oct 21 '16 at 17:57
  • @JaïrPaalman im very sure thats now how its supposed to work, and I would personally not rely on it to be honest. But if it works it works I guess – Hoi_A Oct 21 '16 at 18:00
  • Alright. I downvoted because I already knew about changing the spawn chunks. I didn't want to change the spawn coordinates. That's why I asked for a way to only use command blocks. Further, your code doesn't work. The last code changes the score of the player that is the closest to the command block to 0, ignoring the commands above. Also, I said I was looking for a way to detect when there wasn't a fireball above the player. You answered a different question than the one I asked. The score has to be reset by a shot fireball, but only for the player who shot it. – Jaïr Paalman Oct 21 '16 at 18:10
  • @JaïrPaalman oh, that @p is a major derp on my end xD Also I guess I did misinterpret that question. I dont know of any way to detect movement of a fireball, however, you could run an execute command at the players position but up by X amount of blocks that the fireball is at and do a testfor there which may be slightly more accurate. – Hoi_A Oct 21 '16 at 18:16
  • The problem is that I can't negate the output of the testfor block without a redstone torch and comparator. That's what I'm trying to do. I've tried /execute @a[score_Fireball_min=20] ~ ~ ~ /!testfor @e[type=Fireball] but, as expected, that didn't work. – Jaïr Paalman Oct 26 '16 at 14:41

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.