As the title reads, I am currently trying to get a mob to spawn through a command block when I (or a player) passes through a certain area.

Here is what my set up looks like: [C=command block, < = comporator, I = Redstone Torch, - = Redstone] C < C I - C. So basically in the first command block, I have the command /execute if entity @p[x=(my x),y=(my y),z=(my z)]. Next to the first command block is a comporator leading into another command block.

The second command block has the command, /fill (area below mob spawner command block) minecraft:command_block. On that command block is a redstone torch and a trail of redstone leading into another command block. The final command block / 3rd one has the command, /fill (area below mob spawner command block) minecraft:air. I know I have a stupid mistake in here but my head hurts and I just want a bit of help to guide me on my way.

  • First hint: Don't use redstone with command blocks. You never need it and it has many disadvantages. – Fabian Röling Aug 2 '19 at 5:49
  • Second hint: Spawner? – Fabian Röling Aug 2 '19 at 14:56


Okay assuming this is what you want going just from description then yeah here you go. Note I am not 100% sure this is multiplayer friendly but you can try

1.First either summon an armorstand with /summon armor_stand ~ ~ ~ {Tags:["Near"]} or go in to creative place down an armorstand and type in the command you see in the picture below what ever is easier for you. Note that the Tag name "Near" can be changed to what ever you want, but then you have to stick to it. If you're feeling confused just use "Near" enter image description here

  1. Add a scoreboard named what ever you want, I used Near /scoreboard objectives add Near dummy

3.Put down 4 commandblocks just like in the picture below make sure they are all set to "Always Active", the first one to be repeating, the rest as chained and the last one as chained with "conditional" enter image description here

4.In the first commandblock paste in execute at @e[tag=Near] if entity @p[distance=..2,scores={Near=0}] run scoreboard players set @a Near 1

  1. Second commandblock paste in execute at @e[tag=Near] unless entity @p[distance=..2] run scoreboard players set @a Near 0

  2. Third commandblock paste in execute if score @a[limit=1] Near matches 1 run execute at @e[tag=Near] run summon zombie ~ ~ ~

  3. Last one "scoreboard players set @a Near 2"

  4. Now just write /data merge entity @e[tag=Near,limit=1] {Invisible:1b} in chat to Hide the armorstand

Okay super short explenation cause I've already spent 30 min on this. Command 1 If player is less than 2 blocks away from the armorstand set scoreboard to 1. If you want to change how far away change ..2 to ..x x=what ever distance you like .. means everything under x.

Command 2 if player is not near armorstand set score to 0

Command 3 if score = 1 summon mob this case zombie you can change ~ ~ ~ to cordinates just not that it is not relative to the armorstand

Command 4 if zombie has been summoned set score to 2 so that it won't spawn 1 billion zombies and allows for only 1 zombie to spawn

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.