Updated:
1. Setup (run once)
/scoreboard objectives add lucky_break minecraft.mined:minecraft.sponge
/scoreboard objectives add lucky dummy
/give @a minecraft:sponge 16
lucky_break goes up by one when a player breaks a sponge. lucky holds the roll.
2. Roll for the breaker
# repeat, always active
execute as @a[scores={lucky_break=1..}] store result score @s lucky run random value 1..4
See execute store and the random command.
3. Pick the reward
# chain, always active (every block below)
execute as @a[scores={lucky_break=1..,lucky=1}] run give @s minecraft:diamond 5
execute as @a[scores={lucky_break=1..,lucky=2}] at @s run summon minecraft:zombie ~2 ~ ~
execute as @a[scores={lucky_break=1..,lucky=3}] at @s run summon minecraft:tnt ~ ~1 ~ {fuse:60}
execute as @a[scores={lucky_break=1..,lucky=4}] run effect give @s minecraft:speed 30 1
Diamonds, a zombie, TNT that blows after 3 seconds, or speed. See the TNT command for fuse times.
4. Remove the drop and reset
execute as @e[type=item] if items entity @s contents minecraft:sponge run kill @s
scoreboard players set @a[scores={lucky_break=1..}] lucky_break 0
Removing the dropped sponge stops players from placing the same block again. The reset line must be last, so one break gives one roll.
5. More rewards
Change the roll to 1..10 and add lines for 5 to 10. Two lines with the same reward make it more common.
Troubleshooting
- Nothing happens: only the first block is repeat; the rest are chain.
- Other sponges vanish: every dropped sponge is removed. Pick another block if your world uses sponge.
- Bedrock: there is no mined score or /random, so this setup is Java only (1.20.5 or later).
Check your command
The Command Error Doctor checks common syntax mistakes in your browser.