4

For a map I am making, I am trying to detect when a player boosts with a firework. I've searched all over and cannot find anything. I tried to use

/scoreboard objectives add [name] stat.useItem.minecraft.fireworks

to get a player to a score of 1, then make a repeating command block that does something for all players with a score of one etc, but it only works for launching a firework on a block, not while flying the elytra.

I looked at all of the stat.____ criteria and can't find anything that can seem to do this. Can anyone help?

2

You can do this with just two command blocks:

  1. Make a scoreboard objective with type "dummy" (referred to as [objective]
  2. Make a repeating command block leading into a chain command block (both always active)
  3. Set repeating command block's command to scoreboard players set @a [objective] 0
  4. Set chain command block's command to execute @e[type=fireworks_rocket] ~ ~ ~ scoreboard players set @p[r=1] [objective] 1

This works because when you use a firework while gliding, the fireworks entity still exists and is constantly teleported to the player that used it. The first command reset's all players scores, and the second one sets any players who are rocket gliding score to 1, allowing you to execute commands on anyone who is rocket gliding.

Note: If a player lands while their firework is still active, they are technically still rocket gliding until the rocket runs out. Also, the fireworks will also set players score when placed immediately next to a player.

  • "0.1" - You cannot use decimals with any numerical input for selectors. – Skylinerw Jan 17 '17 at 3:36
  • I tested this in singleplayer 1.11 and it worked fine. – RS_Mind Jan 17 '17 at 3:46
  • In singleplayer you'll not see an issue because you're the only player online. The value is invalid, so if there are multiple players online, they'll all receive a score of 1. You can test this in singleplayer by using an @e selector to modify non-player scores and see the result. See also: this developer comment about decimal values not being supported. – Skylinerw Jan 17 '17 at 3:50
  • Just remembered that there's no reason to use @a over @p – RS_Mind Jan 29 '18 at 1:33

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.