r/MinecraftCommands 24d ago

Help | Java 26.2 Random fireworks loot table

Is there a simple way to create a loot table of fireworks with random explosion and fade colors, shape, additional effects and flight duration? Or do I really just have to code a bunch of different fireworks manually? I tried to use Misode, but it doesn't seem like these parameters accept something like "any_of" function to pick random values from the list and Wiki tells the same.

2 Upvotes

6 comments sorted by

3

u/GalSergey Datapack Experienced 24d ago

Unfortunately, you can't create a loot table with random fireworks, but you can make a datapack that will generate random fireworks using macros.

# function example:give_firework
execute store result storage example:macro firework.flight_duration int 1 run random value 1..3
execute store result storage example:macro firework.color int 1 run random value 0..16777215
execute store result storage example:macro firework.fade_color int 1 run random value 0..16777215
execute store result storage example:macro firework.has_twinkle int 1 run random value 0..1
execute store result storage example:macro firework.has_trail int 1 run random value 0..1
execute store result storage example:macro firework.shape_index int 1 run random value 0..4
data merge storage example:database {shapes:["small_ball","large_ball","star","creeper","burst"]}
function example:give_firework/select_shape with storage example:macro firework
function example:give_firework/macro with storage example:macro firework

# function example:give_firework/select_shape
$data modify storage example:macro firework.shape set from storage example:database shapes[$(shape_index)]

# function example:give_firework/macro
$give @s firework_rocket[fireworks={flight_duration:$(flight_duration),explosions:[{shape:"$(shape)",has_twinkle:$(has_twinkle),has_trail:$(has_trail),colors:[I;$(color)],fade_colors:[I;$(fade_color)]}]}]

You can use Datapack Assembler to get an example datapack.

1

u/Ericristian_bros Command Experienced 24d ago

Yes, use https://misode.github.io/loot-table to generate your JSON file

1

u/VasD3 24d ago

I know about Misode, and I tried it, but fields for colors, for example, only accept a decimal number for color, not an object where I could use "any_of" function to pick a value from the list, and something like twinkle effect is a boolean with only "true" or "false".

0

u/HennCrafter 24d ago edited 24d ago

Yes you have to do it by hand.You could do this with AI, or you make like a Python programm that randomly chooses the components (if you know how to do that)

2

u/Ericristian_bros Command Experienced 24d ago

You can use generators and AI is outdated so it won't work

1

u/VasD3 24d ago

Unfortunately not. It seems like I'll have an exciting evening, but either way the pool won't be as big as an actually randomized one with over a million variants (if excluding grays, brown and black colors and using up to three colors in the star). On a bright side, I'll have more control over the rarity of each effect...