Spawning mobs a few feet away in the direction you are looking at

Spawning mobs a few feet away in the direction you are looking at - From below side view of cheerful female tourist in warm clothes standing on street and reading paper map during sightseeing trip in city

I'll be straight here. I have tried various stupid things, but none seem to be working. What I have for now with a Mob-Spawning kit:

  • Set a command block that tests for any zombie with the name ZombieMaker.

  • Set up command block that kills named zombie.

  • Set it up so that ZombieMinion spawns when ZombieMaker spawns, just before it dies.

    That was background info, because then people start complaining that I haven't tried it out myself. And yes, I have searched for help. The question is:

How do I spawn that Zombie (ZombieMinion) a few blocks away to the direction I, or any player with that kit, is looking at (if possible, where the player was pointing at can also help)?



Best Answer

First, set a row of Command blocks plugged into a clock, testing for the Player approximate roation:

rotation can be tested for using the target selector arguments ry, rym, rx, and rxm, denoting the maximum and minimum view angle in the horizontal (east, south, etc.) and vertical (up, down) direction, respectively.

For example, to test for someone looking South (=0±22), use

testfor @a[ry=22,rym=-22]

(source here)

Then, for each command block set a command to be triggered if the output is true:

/execute @a[SomeSelector] ~ ~ ~ summon Zombie x y z {YourNBTTag}

Instead of x y z put the relative coordinates you want (for each CMD block pair a different set).
That would be, 4 * 2 or 8 * 2 CMD blocks altogether, depending on the accuracy you want.




Pictures about "Spawning mobs a few feet away in the direction you are looking at"

Spawning mobs a few feet away in the direction you are looking at - Smiling female tourist with paper map on street
Spawning mobs a few feet away in the direction you are looking at - Young ethnic woman pointing at camera
Spawning mobs a few feet away in the direction you are looking at - Woman Walking on Pathway Under The Sun



What is the best distance for mobs to spawn?

Mobs won't spawn closer than 24 blocks. They won't move around when farther than 32 blocks.

How far beneath you can mobs spawn?

A mob spawner will only spawn a new mob if a player is within 16 blocks of it (calculated spherically).



WorldGuard: How to stop mobs from spawning in Minecraft




More answers regarding spawning mobs a few feet away in the direction you are looking at

Answer 2

The generic command summon an entity is:

/summon <EntityName> [x] [y] [z] [dataTag]

So in order to summon a zombie in your current location you should type:

/summon Zombie ~ ~ ~

You could also try adding to the current location /summon Zombie ~1 ~ ~

Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Andrea Piacquadio, Andrea Piacquadio, Andrea Piacquadio, Andrea Piacquadio