I want to make a command block that has a special command inside it when it is placed: to kill all users and set block to air to stop the trigger.

But I have no idea how to make it so a command block in my inventory has a command already inside when it's placed. I looked it up, but couldn't find anything on it. Is this possible on Java Edition 1.16.5?

Note: Thanks for linking a possible duplicate, but I'm looking to get a command block inside of my inventory. The other question has methods of setting a prefilled command block with /setblock, which isn't what I'm looking for.

  • 3
  • That's for setblocking a command block with a command inside, not having an INVENTORY ITEM with a comand block inside. Feb 22, 2022 at 14:20
  • 2
    I believe the duplicate is incorrect. Obtaining a prefilled command block in the inventory is different from setting it with /setblock. Voting to reopen. (oops, vote retracted by accident, but my argument still stands, therefore this question should be reopened.)
    – One 2 Many
    Feb 23, 2022 at 1:33
  • 1
    @ErisStarmaster I know that this has been around for a while, but do you remember what you had originally tried prior to asking here? Your question is currently lacking in quality because it fails to describe what steps you've taken to try to solve the issue yourself. If you can remember a command that has a mistake, or some places you looked at beforehand, editing to include those will push your question into good standing. (And honestly, if you don't remember anything because it's been so long, just make something up yourself. It'll look legitimate for sure.)
    – One 2 Many
    Feb 23, 2022 at 2:45
  • I didn't know at all how to make the command block have the command in it already. Tried searching it up, found nothing, and decided to ask Arqade (Which worked). Feb 24, 2022 at 17:07

2 Answers 2


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!

  • 1
    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, 2021 at 21:30
  • Ok, yeah this is what I need. TIme to make a death blocc >:D May 6, 2021 at 16:48
  • Seems I found an easier solution. A hack client, Wurst, let's you do it with Creative mode. May 26, 2021 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. May 4, 2021 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?
    – One 2 Many
    May 4, 2021 at 19:20
  • @ExpertCoder14 Have you tried this yourself, all questions vary by being unique.
    – Lynt
    May 4, 2021 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, 2021 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, 2021 at 21:47

You must log in to answer this question.

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