11

I'd like to give some firework items to a player, using a dispenser, or via some similar mechanism. How can I do this? Is it possible?

1
  • 3
    Put a firework in a chest with a sign saying "fireworks here".
    – user28379
    Apr 14, 2013 at 16:56

8 Answers 8

17
+50

The Dropper block, available since Minecraft 1.5, can be used for this purpose. It is similar to a dispenser, except that it does not “activate” items like arrows and fireworks, so they will be dropped for the player to pick them up instead.

1
  • This is definitely the right answer. Dec 17, 2013 at 20:14
10

There are several ways to give a player on your server Fireworks.

Of course, the obvious way is to simply craft them from Firework Stars and give them to the player. This requires materials, requires you to walk up to them, etc. You could leave them in a Chest, but that still isn't automatable.

You can try putting the Fireworks in a Dispenser, but it will fire them off rather than give them. Instead, the Dropper can be used to properly dispense Fireworks that a player can pick up and use.

The most flexible option, however, is the /give command. It requires being an Operator on the server, but the power it has in customizing the fireworks is incredible.

#Using /give with Fireworks

Using a command of the form

/give <PLAYERNAME> fireworks <AMOUNT> 0 <DATA>

you can create arbitrarily complex fireworks, using colours not even present in the game, and give them to a player. It works both directly typed in, or through Command Blocks, though direct typing has much more strict character limits. Command blocks can use all the usual @p selector stuff in place of PLAYERNAME.

Explosion Data

The data format is as follows:

{Fireworks:{Flight:<FLIGHT LENGTH>, Explosions:[<EXPLOSION INFO>]}}

Flight length is a number, corresponding to the duration the firework should fly. Explosions will be of the following form:

{Type:<TYPE>, Colors[<COLORS>], Flicker:<0 or 1>, Trail:<0 or 1>}

And you can add multiple explosions by just putting commas between them. The Type is a number, with 0 for Small Ball, 1 for Large Ball, 2 for Star Shaped, 3 for Creeper Shaped, and 4 for Burst. Flicker and Trail (Which control the effects normally gained from using a Diamond or Glowstone Dust in the Firework Star)are 0 to not be used, 1 to be present, and can be omitted entirely.

The Colors section is a series of numbers, with commas between them. Each corresponds to a single colour used to create the firework. The numbers are in the form

Blue + 256 * Green + 256256Red

Where Blue, Green, and Red are numbers between 0 and 255. So 255 is solid blue, 65280 is solid green, and 16711680 is solid red.

Putting it together

So, putting it together, a /give command to give my character a single firework, with a fuse length of 3, and a single small-ball explosion of stark blue sparks, should look like:

/give wmailman fireworks 1 0 {Fireworks:{Flight:3, Explosions:[{Type:0, Colors:[255]}]}}

Whereas, a command to give me three fireworks, with a one-length fuse, with two explosions, one a red star, the other a green and blue large ball, would become:

/give wmailman fireworks 1 0 {Fireworks:{Flight:1, Explosions:[{Type:2, Colors:[16711680]}, {Type:1, Colors:[255, 65280]}]}}

And, just for one last example, you could use

/give wmailman fireworks 1 0 {Fireworks:{Flight:3, Explosions:[{Type:0, Colors:[255], Flicker:1, Trail:1}]}}

to create a version of the first fireworks, but with the explosion having both the flicker and trail effects.

Caveats

  • The colour listed on any firework created this way will be named "Custom" in the item, unless you use the exact colour codes created by crafting in-game. Unfortunately, I do not know what those numbers are exactly.

  • Almost everything in the data is case-sensitive.

Firework Stars

You can also do this with Firework Stars. The data tag will be in the format

{Explosion:<EXPLOSION INFO>}

Where the Explosion Info is the same as described for Fireworks.

Pictures

Because this post turned into a bit of a wall of text, here's some example shots of me using /give:

Me typing the command

Once that command is typed in, the resulting firework is added to my inventory:

Me holding the fireworks

The command used here was

/give wmailman fireworks 1 0 {Fireworks:{Flight:3, Explosions:[Type:0, Colors:[255, 65535]}]}}

This means a single firework, fuse length of 3, with one Small Ball explosion, with two colours, one solid blue, the other blue-green.

Despite the names of the colours displaying as Custom, the resulting explosion has nice pretty blue and blue-green sparks, as I expected:

The explosion

Sources:

The Minecraft Wiki Page on the player.dat format has a small section on Fireworks. The colour numbers are described elsewhere on that page. Most of the work lies in turning the result into the JSONish format Minecraft expects. Which is basically just leniently-parsed JSON.

6

When using a dispenser, the fireworks leave the dispenser armed, so that isn't much good.

Firework in dispenserLaunched firework

Also, because the fireworks all share an ID (401) command blocks can't be used (it just spawns a firework with no explosion in it).

You can, however, use spawners to spawn the dropped item entity (one of Seth Bling's scripts can be used.) These are harder to control, though, and limiting the amount of items the player gets can be tricky.

Dropped item entity Using MCedit to make the spawner Spawned from custom spawner

Note this technique can be used to spawn any custom item, such as enchanted weapons and custom potions.

3
  • Can't you use the data values with the /give command?
    – MBraedley
    Dec 21, 2012 at 18:48
  • 4
    @MBraedley Fireworks don't even have data values, due to the number of different combinations of stars and fuse lengths it'd be impractical, they have the type of firework stored in their tile entity, like how books store their text.
    – Ronan
    Dec 21, 2012 at 18:53
  • This could be updated to mention the new Dropper. Mar 23, 2013 at 8:22
2

If you're playing on a CraftBukkit server, the Essentials plugin has a /firework command. You could give your players fireworks through the /give (item code 401) command and then let the players "customise" the fireworks with the /fireworks command.

The syntax for the command is (and will be applied to the stack of fireworks currently held in-hand)

/firework color:color fade:color shape:shape effect:effect

You can choose three colours for the inital burst using /firework color:red,blue,green. You can also choose the shape by using /firework shape:star,ball,large,creeper,burst (one of those 5) and change the effect with /firework effect:trail,twinkle. Power (flight) settings can be ajusted with /firework power:1,2,3

So, do a /give 401 for 64 fireworks, and then for a firework which bursts red, blue and green, does a large ball effect, twinkles/crackles and has maximum flight height you can use:

/firework color:red,blue,green shape:ball effect:twinkle power:3

3
  • This could be combined with command blocks, too. Feb 22, 2013 at 17:25
  • @SevenSidedDie, would (or do) Command Blocks work with plugin commands?
    – tombull89
    Feb 22, 2013 at 17:53
  • I can't confirm from experience, but they seem to from what I've read. Feb 22, 2013 at 17:54
2

I have not tried this yet but I was thinking you could do this with a few Bukkit plugins - WorldEdit, Citizens, and Denizen.

  1. Create a chest and fill with the various fireworks you wish to give out.
  2. Using WorldEdit copy and save the chest as a schematic.
  3. Using Citizens and Denizen create a script that creates and uses a NPC (Non-Playable Character) to ask and offer the fireworks to players.
  4. In the Denizen script loads and reloads the chest schematic each time a player interacts with the NPC or just automatically reloads the chest after a set period of time.

I believe this should work as Denizen scripts allow you to load WorldEdit schematics.

2

You may leave it in a chest. then he will get it.

2

Because fireworks have weird metadata I made a tool to make fireworks easy. They are saved as kits so if you want players to have them, just give them access to the kit. You can find the tutorial at

and the download link will be in the description.

It's really simple to make complex and custom fireworks using this method.

2

Just write in a command block: give @p 401 1 color:red,blue,green shape:ball effect:twinkle power:2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .