pos Camera

Creates a new camera (or player) position: right/left, up/down, in front/behind.

posCamera(0, 0, 0)

A camera position is also known as a player position. It is the relative distance in each direction from where the player is currently heading, starting at point of the player’s feet.

If the player is heading in a Northwest direction, the distance in front is in the North direction if the player’s heading is more toward the North than the West. In the following example, an orange concrete block is placed in front of the player. This code will place the block on the North side of the player since the player is heading more toward the North.

blocks.place(ORANGE_CONCRETE, posCamera(0, 0, 5))

Block placed with a player position

Read about how different types of positions work in the positions reference.

Parameters

  • x: the right (+x) or left (-x) distance from the player, in blocks.
  • y: the up (+y) or down (-y) distance from the player, in blocks.
  • z: the forward (+z, in front) or backward (-z, behind) distance from the player, in blocks.

Example

Make two chat commands. One command creates a two-axis marker in the ground using relative coordinates. The other command will place a block of diamond at a distance of 5 blocks in front of the player. Have the player face toward the Northwest direction on the coordinate axes of polished andesite and place a diamond block.

player.onChat("twoaxis", function () {
    for (let index = 0; index <= 16; index++) {
        blocks.place(POLISHED_ANDESITE, pos(0, -1, index))
        blocks.place(POLISHED_ANDESITE, pos(0, -1, -1 - index))
        blocks.place(POLISHED_ANDESITE, pos(index , -1, 0))
        blocks.place(POLISHED_ANDESITE, pos(-1 - index , -1, 0))
    }
blocks.print(
    "N",
    YELLOW_CONCRETE,
    pos(0, 3, -33),
    EAST
    )
    blocks.print(
    "W",
    YELLOW_CONCRETE,
    pos(-33, 3, 0),
    NORTH
    )
})

player.onChat("placeplayer", function () {
    blocks.place(DIAMOND_BLOCK, posCamera(0, 0, 5))
})

See Also

||positions:world||, ||positions:local||