Minecraft Java Edition – How to Summon Primed TNT at a Player’s Feet

minecraft-commandsminecraft-java-edition

I want to have explosive consequences for breaking rules, if you place a bed primed TNT appears at your feet, if you try to sleep in a bed same, and same if you try to kill another player, so please just give me how to do one of those and I can modify it for the rest.

Best Answer

This answer will show you how to summon the TNT when you kill another player.

Begin by creating the objective playerkill to detect when a player kills another player:

/scoreboard objectives add playerkill playerKillCount

Next, create a repeat command block (set to 'always active') and a chain command block, containing these commands:

/execute @a[score_playerkill_min=1] ~ ~-1 ~ summon PrimedTnt ~ ~ ~ {Fuse:0}
/scoreboard players set @a[score_playerkill_min=1] playerkill 0

These will check every tick whether or not a player has killed another player, and summons a primed TNT below their feet if they have. Then it resets the player killer's score to zero, so the player isn't constantly killed.

Demonstration: (note I have manually set my score to 1, since I do not have another player to murder test with)

When I 'kill' another player, I instantly explode