Some backstory. I wanted to make a command block that had a simple command when placed: Kill all users and set block to air to stop the trigger.
However, I had no idea how to make it so a command block had commands already input on place.
Is this possible? (Version 1.16.5)


You can do this from scratch with /setblock:

setblock 12 23 34 minecraft:command_block[]{Command:"…"}

Your command goes inside those quotation marks right there.

If you are looking to get this command block as an inventory item, use BlockEntityTag like so:

give @p minecraft:command_block{BlockEntityTag:{Command:"…"}}

Beware as you will need to escape quotation marks in your inner command, which can lead to messes like these!

  • Primarily beware to make the block self-destruct as intended, because an always-active /kill @p is a recipe for a disaster. – SF. May 4 at 21:30
  • Ok, yeah this is what I need. TIme to make a death blocc >:D – Eris Starmaster May 6 at 16:48
  • Seems I found an easier solution. A hack client, Wurst, let's you do it with Creative mode. – Eris Starmaster May 26 at 12:23

So make the command block with the command to make it so it kills when placed and set to always active then I think it hold shift and click the block and the code should stay in the command block.

  • 1
    Hm. If this works, I have to test it. Ill get a chance later on. – Eris Starmaster May 4 at 17:44
  • 1
    No, this won't work unfortunately. Holding shift and clicking on the block breaks it. Perhaps you meant Ctrl + middle click? – ExpertCoder14 May 4 at 19:20
  • @ExpertCoder14 Have you tried this yourself, all questions vary by being unique. – Wabbit. May 4 at 20:09
  • 1
    @Wabbit shift+left cliick in creative mode is a regular 'destroy block while crouching', and it acts on command blocks just the same as on dirt. – SF. May 4 at 21:27
  • @Wabbit. what do you even mean? He said it wouldn't work and your response is... I'm not even sure tbh. – Penguin May 4 at 21:47

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.