1

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.

3

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.

  • Hey, this is perfect but what about replacing other blocks; for example, I place red wool, and I want to replace all the red wool with a prefilled dispenser? – Alex Diamond Jul 26 '16 at 5:32
  • When you set [oldBlockHandling] to replace, the syntax changes. There's no way to use a data tag with replace. – MrLemon Jul 26 '16 at 8:15
  • @MrLemon It's actually the opposite: if the block ID has a tile entity variant, it will only accept NBT input. This prevents us from replacing a specific block with a tile entity. See also this comment on MC-61864. – Skylinerw Jul 26 '16 at 11:08
2

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

0

This is what your command is supposed to be:

/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}]}}
0

/fill ~ ~ ~ ~15 ~ ~11 minecraft:dispenser 0 replace {Items:[{id:"tnt",Count:64b,Slot:0b}]} i made this, its a 15 x 11 format for a chaos cannon, only 1 stack of tnt but it will always fit in the chat box

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.