Skip to content

API reference Obsidian.API.Blocks

BlockPlaceContext class

A player placing a block (see IBlockBehavior.GetStateForPlacement), like vanilla's BlockPlaceContext.

public sealed class BlockPlaceContext

In Obsidian.API.

Constructors

public BlockPlaceContext();

Properties

Block

public required IBlock Block { get; init; }

The block's default state.

ClickedAt

public required VectorD ClickedAt { get; init; }

Where on the clicked block the player clicked, from its lowest corner: 0 to 1 on each axis.

ClickedFace

public required BlockFace ClickedFace { get; init; }

The face of the clicked block the player clicked.

ClickedPosition

public required Vector ClickedPosition { get; init; }

The block the player clicked.

public required InteractionHand Hand { get; init; }

HorizontalDirection

public required BlockFace HorizontalDirection { get; init; }

The horizontal direction the player faces (north, south, west or east), like vanilla's getHorizontalDirection. Blocks that face the player use its opposite.

Item

public required ItemStack Item { get; init; }

The item the player places the block with.

Level

public required IBlockLevel Level { get; init; }

The level, for reading the blocks around; the block isn't placed yet.

NearestLookDirection

public required BlockFace NearestLookDirection { get; init; }

The direction, of all six, closest to where the player looks, like vanilla's getNearestLookingDirection.

public required IPlayer Player { get; init; }

Position

public required Vector Position { get; init; }

Where the block goes: BlockPlaceContext.ClickedPosition when it replaces the clicked block, otherwise next to it on the clicked face.

ReplacesClicked

public required bool ReplacesClicked { get; init; }

Whether the block replaces the clicked block (tall grass, say) rather than going next to it.

On this page