Minecraft – way to place a command block with a command in a chest and/or dispenser

minecraft-java-editionminecraft-redstone

I'm in the new snapshot and trying to make a random TP out of a dispenser and command blocks just like SethBling in his snapshot video just with the difference that I want to place the dispenser with an infinity amount of command blocks instead of 64 of each.

SethBling's video, relevant point about 14 minutes in:

Best Answer

To get a command block item with a command datatag:

  • Place down a command block
  • Type in the command you want
  • Hold CTRL
  • Middle click the command block

You should be able to see a "+NBT" in purple below the item name when you hover over it, indicating that the item has extra data. You can then put this in dispensers, chests, etc.

The easiest way to have limitless command blocks would be to have a "template dispenser" with all of your custom command blocks in that never gets activated, and then have the activation button clone the template down onto where you want the actual dispenser. A setup like this will work:

enter image description here