Table of Contents

Class BlockSelection

Namespace
Vintagestory.API.Common
Assembly
VintagestoryAPI.dll

Contains all the information for a players block selection event

public class BlockSelection
Inheritance
BlockSelection
Inherited Members

Constructors

BlockSelection()

public BlockSelection()

BlockSelection(BlockPos, BlockFacing, Block)

Creates a basic BlockSelection from limited data

public BlockSelection(BlockPos pos, BlockFacing face, Block block)

Parameters

pos BlockPos
face BlockFacing
block Block

Fields

Block

The block actually being looked at!

public Block Block

Field Value

Block

DidOffset

Always false during block use. True during placement if the Position value was offseted. Example:

  • When trying to place planks while aiming at rock, the Position is the one in front of the Rock and DidOffset is True
  • When trying to place planks while aiming at tallgrass, the Position is where the tall grass is and DidOffset is false (because tallgrass is replacable)
public bool DidOffset

Field Value

bool

Face

The face the player aimed at

public BlockFacing Face

Field Value

BlockFacing

HitPosition

The coordinate of the exact aimed position, relative to the Block Position

public Vec3d HitPosition

Field Value

Vec3d

Position

The position the player wants to place/break something at

public BlockPos Position

Field Value

BlockPos

SelectionBoxIndex

Which selection box was aimed at. The index corresponds to the array returned by Block.GetSelectionBoxes()

public int SelectionBoxIndex

Field Value

int

Properties

FullPosition

public Vec3d FullPosition { get; }

Property Value

Vec3d

Methods

Clone()

Creates a deep copy

public BlockSelection Clone()

Returns

BlockSelection

GetDecorIndex(BlockFacing)

Turn face to a decor index

public static int GetDecorIndex(BlockFacing face)

Parameters

face BlockFacing

Returns

int

GetDecorIndex(BlockFacing, int, int, int)

Turn face and local voxel position to a decor index

public static int GetDecorIndex(BlockFacing face, int vx, int vy, int vz)

Parameters

face BlockFacing
vx int

0..15

vy int

0..15

vz int

0..15

Returns

int

ToDecorIndex()

Returns a subposition index for use addressing decor subpositions on a block

public int ToDecorIndex()

Returns

int