Fill and Replace command with prefilled dispenser?

I'm creating a TNT cannon with dispensers and a clock. It's a long tower of dispensers and after the cannon is done firing TNT, you have to painfully refill it or at least replace it with this /give given dispenser;

/give @p dispenser 1 0 {BlockEntityTag:{Items:[{id:"tnt",Count:64b,Slot:0b}, {id:"tnt",Count:64b,Slot:1b}, {id:"tnt",Count:64b,Slot:2b},{id:"tnt",Count:64b,Slot:3b}, {id:"tnt",Count:64b,Slot:4b}, {id:"tnt",Count:64b,Slot:5b}, {id:"tnt",Count:64b,Slot:6b}, {id:"tnt",Count:64b,Slot:7b}, {id:"tnt",Count:64b,Slot:8b}]}}

I know how to use the /fill command but is it possible to fill blocks with a prefilled dispenser?

Like this; /fill ~ ~ ~ ~5 ~ ~5 dispenser 0 {FILLED ITEMS} replace wool 14

The above should replace all red wool within the relative dimensions of 6x6x1 with prefilled dispensers.


Your fill statement is almost correct. You have to specify oldBlockHandling, as per the syntax of the command:

fill <x1> <y1> <z1> <x2> <y2> <z2> <TileName> [dataValue] [oldBlockHandling] [dataTag]

(http://minecraft.gamepedia.com/Commands#fill)

Your command would look like this:

/fill ~ ~ ~ ~5 ~ ~5 minecraft:dispenser 0 replace {Items:[{id:"tnt",Count:64b,Slot:0b}, {id:"tnt",Count:64b,Slot:1b}, {id:"tnt",Count:64b,Slot:2b},{id:"tnt",Count:64b,Slot:3b}, {id:"tnt",Count:64b,Slot:4b}, {id:"tnt",Count:64b,Slot:5b}, {id:"tnt",Count:64b,Slot:6b}, {id:"tnt",Count:64b,Slot:7b}, {id:"tnt",Count:64b,Slot:8b}]}

Note that if you want to change the rotation of the dispenser, you would change the dataValue.


I came up with an alternate solution. You set up a location where your cannon is fully loaded, then you grab the dimensions of that location and clone it over where you want your cannon to be (or originally is). So, to fill it, you simply clone your fully loaded model to the location of your empty model.

/clone Command:

/clone x1 y1 z1 x2 y2 z2 x y z replace force

Put the above in a command block with a button I guess.

  • x1 y1 z1 = top left corner of fully loaded cannon.
  • x2 y2 z2 = bottom right corner of fully loaded cannon.
  • x y z = top left corner of empty cannon.
  • replace = replaces all existing blocks at x y z (not required).
  • force = force copies everything from source even if they overlap (not required).

Simple Model (might be difficult to understand):

  • [ ] = Dispenser filled with TNT [Arrows = face direction]
  • [î] = Dispenser filled with TNT facing north and Redstone Torch on top
  • [^] = Dispenser facing north, water underneath
  • [s] = Stone Slab
  • r = Redstone Dust
  • b = Button
  • 1 = x1, y1, z1
  • 2 = x2, y2, z2
  • 3 = x, y, z

Original Model : Using Model

    1   [s]            3   [s]

    [>] [^] [<]        [>] [^] [<]

     r  [î] r           r  [î] r  

         b   2              b

It's probably best to hide the original model somewhere out of site.

Syntax and Details on /clone Here