near

Selects targets near a position.

mobs.near(
    mobs.target(LOCAL_PLAYER),
    world(0, 0, 0),
    5
);

Parameters

  • target: the type of mobs to select:
    • local player: select the current player (you)
    • nearest player: select the player nearest to the world origin
    • random player: select a random player in the world
    • all players: select all players in the world
    • all entities: select all players and mobs
    • my agent: select the agent
  • pos: the position near where you want to select targets
  • radius: how far away (in blocks) you want to go to select targets, like: 5 blocks

Example

Teleport all chickens within 15 blocks of the player high in the sky.

mobs.teleportToPosition(
    mobs.near(
        mobs.entitiesByType(CHICKEN),
        player.position(),
        15
    ),
    pos(0, 30, 0)
);

See Also

||mobs:target||, ||positions:positions||

Read more about target selectors in the Minecraft wiki.