Table of Contents

Struct BlockIndex

Namespace
Shard.Gameplay.Universe.World.Blocks
Assembly
Shard.Gameplay.Universe.dll

The flattened index of a block inside a 32x32x32 chunk. Consists of an uns

public readonly record struct BlockIndex : IComparable, IComparable<BlockIndex>, IEquatable<BlockIndex>
Implements
Inherited Members

Remarks

Value is formed by combining the axes into one 15-bit value. The five least-significant bits are the X axis, the next five are the Z axis, and the last five are the Y axis. All other bits should be zero.

Constructors

BlockIndex(int)

The flattened index of a block inside a 32x32x32 chunk. Consists of an uns

public BlockIndex(int Value)

Parameters

Value int

The raw index value, in the range 0..32768.

Remarks

Value is formed by combining the axes into one 15-bit value. The five least-significant bits are the X axis, the next five are the Z axis, and the last five are the Y axis. All other bits should be zero.

BlockIndex(int, int, int)

public BlockIndex(int x, int y, int z)

Parameters

x int
y int
z int

Properties

Value

The raw index value, in the range 0..32768.

public int Value { get; init; }

Property Value

int

X

X value. Values are in the range 0..32, where 0 is farthest west and 31 is farthest east.

public int X { get; }

Property Value

int

Y

Y value. Values are in the range 0..32, where 0 is lowest down and 31 is highest up.

public int Y { get; }

Property Value

int

Z

Z value. Values are in the range 0..32, where 0 is farthest north and 31 is farthest south.

public int Z { get; }

Property Value

int

Methods

CompareTo(BlockIndex)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(BlockIndex other)

Parameters

other BlockIndex

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

CompareTo(object?)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(object? obj)

Parameters

obj object

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes obj in the sort order.
Zero This instance occurs in the same position in the sort order as obj.
Greater than zero This instance follows obj in the sort order.

Exceptions

ArgumentException

obj is not the same type as this instance.

Deconstruct(out int, out int, out int)

public void Deconstruct(out int x, out int y, out int z)

Parameters

x int
y int
z int

Operators

implicit operator int(BlockIndex)

public static implicit operator int(BlockIndex index)

Parameters

index BlockIndex

Returns

int

implicit operator (int, int, int)(BlockIndex)

public static implicit operator (int, int, int)(BlockIndex index)

Parameters

index BlockIndex

Returns

(int, int, int)

implicit operator BlockIndex(int)

public static implicit operator BlockIndex(int value)

Parameters

value int

Returns

BlockIndex

implicit operator BlockIndex((int, int, int))

public static implicit operator BlockIndex((int, int, int) xyz)

Parameters

xyz (int, int, int)

Returns

BlockIndex