1

I want to make it so you place a dispenser at the nearest player's location (if the nearest player is not available, than I could just use me). I can't just make the coordinates ~ ~ ~ because I'm using this command from a command block, and that would just place the block at the location of the command block. Here is what I've got so far:

/setblock (this is where I need help) minecraft:dispenser 2 keep {Items:[{id:35, Slot:0, Count:-1,Data:0}]}

Just so you guys know, most of the command is specific to what I need to do, the basic form of this is:

/setblock (this is where I need help) minecraft:dispenser 2
3

The full command you want should be this:

/execute @p ~ ~ ~ /setblock ~ ~ ~ minecraft:dispenser 2 keep {Items:[{id:35, Slot:0, Count:-1,Data:0}]}

The "execute" command takes a selector, a set of coordinates, and another command. It runs that other command as if the selected entity was running it. For example:

/execute @p ~ ~ ~ /say hello

Would make the closest player say "hello", even if a command block or another player is actually running the command above.

  • You main want to change ~ ~ ~ to ~ ~-1 ~ as to not place the block inside the player. – DatEpicCoderGuyWhoPrograms Oct 20 '14 at 22:55

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.