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.
Constructors
Section titled “Constructors”| Member | Description |
|---|---|
BlockState(uint id) |
Wraps a state id. |
Constructor
Section titled “Constructor”public BlockState(uint id)Wraps a state id.
Parameters
| Name | Type | Description |
|---|---|---|
id |
uint |
The global palette id. |
Fields
Section titled “Fields”| 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).
Properties
Section titled “Properties”| 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). |
BlockKey
Section titled “BlockKey”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).
Methods
Section titled “Methods”| 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. |
Equals
Section titled “Equals”public bool Equals(BlockState other)Parameters
| Name | Type | Description |
|---|---|---|
other |
BlockState |
Returns bool
Equals
Section titled “Equals”public override bool Equals(object? obj)Parameters
| Name | Type | Description |
|---|---|---|
obj |
object? |
Returns bool
GetHashCode
Section titled “GetHashCode”public override int GetHashCode()Returns int
ToString
Section titled “ToString”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.
TryParse
Section titled “TryParse”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.
Operators
Section titled “Operators”| Member | Description |
|---|---|
static bool operator !=(BlockState a, BlockState b) |
Inequality. |
static bool operator ==(BlockState a, BlockState b) |
Equality. |
operator !=
Section titled “operator !=”public static bool operator !=(BlockState a, BlockState b)Inequality.
Parameters
| Name | Type | Description |
|---|---|---|
a |
BlockState |
|
b |
BlockState |
Returns bool
operator ==
Section titled “operator ==”public static bool operator ==(BlockState a, BlockState b)Equality.
Parameters
| Name | Type | Description |
|---|---|---|
a |
BlockState |
|
b |
BlockState |
Returns bool