Skip to content

BlockState

Namespace Mc.Scripting.Worlds · Kind struct (readonly)

public readonly struct BlockState : IEquatable<BlockState>

A block state: a block plus its properties, as the numeric id of the global palette. Blittable.

Member Description
BlockState(uint id) Wraps a state id.
public BlockState(uint id)

Wraps a state id.

Parameters

Name Type Description
id uint The global palette id.
Member Description
readonly uint Id The numeric id in the vanilla block state registry (0 = air).
public readonly uint Id;

The numeric id in the vanilla block state registry (0 = air).

Member Description
string BlockKey { get; } The block key without properties (“minecraft:oak_stairs”).
bool IsAir { get; } Whether this is the air block.
string Key { get; } The state as text, e.g.
static BlockState Air { get; } Air (id 0).
public string BlockKey { get; }

The block key without properties (“minecraft:oak_stairs”).

public bool IsAir { get; }

Whether this is the air block.

public string Key { get; }

The state as text, e.g. “minecraft:oak_stairs[facing=north,half=bottom,shape=straight,waterlogged=false]”.

public static BlockState Air { get; }

Air (id 0).

Member Description
bool Equals(BlockState other)
override bool Equals(object? obj)
override int GetHashCode()
override string ToString()
static BlockState Parse(string text) Parses “minecraft:stone” or “minecraft:oak_stairs[facing=north]” (missing properties take the block’s defaults).
static bool TryParse(string text, out BlockState state) Parses a block state text.
public bool Equals(BlockState other)

Parameters

Name Type Description
other BlockState

Returns bool

public override bool Equals(object? obj)

Parameters

Name Type Description
obj object?

Returns bool

public override int GetHashCode()

Returns int

public override string ToString()

Returns string

public static BlockState Parse(string text)

Parses “minecraft:stone” or “minecraft:oak_stairs[facing=north]” (missing properties take the block’s defaults).

Parameters

Name Type Description
text string The block state text.

Returns BlockState: The state.

Throws

  • System.FormatException: The text names no known block state.
public static bool TryParse(string text, out BlockState state)

Parses a block state text.

Parameters

Name Type Description
text string The text.
state out BlockState The state when parsing succeeded.

Returns bool: Whether the text named a known block state.

Member Description
static bool operator !=(BlockState a, BlockState b) Inequality.
static bool operator ==(BlockState a, BlockState b) Equality.
public static bool operator !=(BlockState a, BlockState b)

Inequality.

Parameters

Name Type Description
a BlockState
b BlockState

Returns bool

public static bool operator ==(BlockState a, BlockState b)

Equality.

Parameters

Name Type Description
a BlockState
b BlockState

Returns bool