Skip to content

Class ProtocolVersion

Namespace: Void.Minecraft.Network
Assembly: Void.Minecraft.dll

Represents a numeric Minecraft Java Edition protocol version and the releases that share it.

[JsonConverter(typeof(ProtocolVersionJsonConverter))]
public class ProtocolVersion : IComparable

Inheritance

objectProtocolVersion

Implements

IComparable

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Remarks

Constructing an instance registers its numeric value process-wide. Protocol versions compare and test equality by , not by release names or reference identity.

Constructors

ProtocolVersion(int, params ReleaseVersion[])

Initializes and globally registers a protocol version.

public ProtocolVersion(int value, params ReleaseVersion[] names)

Parameters

value int

The numeric protocol identifier.

names ReleaseVersion[]

The releases that use the identifier. The supplied array is retained without copying and can be empty.

Exceptions

InvalidOperationException

value is already registered.

Fields

MINECRAFT_1_10

Represents releases 1.10 through 1.10.2 using protocol 210.

public static readonly ProtocolVersion MINECRAFT_1_10

Field Value

ProtocolVersion

MINECRAFT_1_11

Represents release 1.11 using protocol 315.

public static readonly ProtocolVersion MINECRAFT_1_11

Field Value

ProtocolVersion

MINECRAFT_1_11_1

Represents releases 1.11.1 and 1.11.2 using protocol 316.

public static readonly ProtocolVersion MINECRAFT_1_11_1

Field Value

ProtocolVersion

MINECRAFT_1_12

Represents release 1.12 using protocol 335.

public static readonly ProtocolVersion MINECRAFT_1_12

Field Value

ProtocolVersion

MINECRAFT_1_12_1

Represents release 1.12.1 using protocol 338.

public static readonly ProtocolVersion MINECRAFT_1_12_1

Field Value

ProtocolVersion

MINECRAFT_1_12_2

Represents release 1.12.2 using protocol 340.

public static readonly ProtocolVersion MINECRAFT_1_12_2

Field Value

ProtocolVersion

MINECRAFT_1_13

Represents release 1.13 using protocol 393.

public static readonly ProtocolVersion MINECRAFT_1_13

Field Value

ProtocolVersion

MINECRAFT_1_13_1

Represents release 1.13.1 using protocol 401.

public static readonly ProtocolVersion MINECRAFT_1_13_1

Field Value

ProtocolVersion

MINECRAFT_1_13_2

Represents release 1.13.2 using protocol 404.

public static readonly ProtocolVersion MINECRAFT_1_13_2

Field Value

ProtocolVersion

MINECRAFT_1_14

Represents release 1.14 using protocol 477.

public static readonly ProtocolVersion MINECRAFT_1_14

Field Value

ProtocolVersion

MINECRAFT_1_14_1

Represents release 1.14.1 using protocol 480.

public static readonly ProtocolVersion MINECRAFT_1_14_1

Field Value

ProtocolVersion

MINECRAFT_1_14_2

Represents release 1.14.2 using protocol 485.

public static readonly ProtocolVersion MINECRAFT_1_14_2

Field Value

ProtocolVersion

MINECRAFT_1_14_3

Represents release 1.14.3 using protocol 490.

public static readonly ProtocolVersion MINECRAFT_1_14_3

Field Value

ProtocolVersion

MINECRAFT_1_14_4

Represents release 1.14.4 using protocol 498.

public static readonly ProtocolVersion MINECRAFT_1_14_4

Field Value

ProtocolVersion

MINECRAFT_1_15

Represents release 1.15 using protocol 573.

public static readonly ProtocolVersion MINECRAFT_1_15

Field Value

ProtocolVersion

MINECRAFT_1_15_1

Represents release 1.15.1 using protocol 575.

public static readonly ProtocolVersion MINECRAFT_1_15_1

Field Value

ProtocolVersion

MINECRAFT_1_15_2

Represents release 1.15.2 using protocol 578.

public static readonly ProtocolVersion MINECRAFT_1_15_2

Field Value

ProtocolVersion

MINECRAFT_1_16

Represents release 1.16 using protocol 735.

public static readonly ProtocolVersion MINECRAFT_1_16

Field Value

ProtocolVersion

MINECRAFT_1_16_1

Represents release 1.16.1 using protocol 736.

public static readonly ProtocolVersion MINECRAFT_1_16_1

Field Value

ProtocolVersion

MINECRAFT_1_16_2

Represents release 1.16.2 using protocol 751.

public static readonly ProtocolVersion MINECRAFT_1_16_2

Field Value

ProtocolVersion

MINECRAFT_1_16_3

Represents release 1.16.3 using protocol 753.

public static readonly ProtocolVersion MINECRAFT_1_16_3

Field Value

ProtocolVersion

MINECRAFT_1_16_4

Represents releases 1.16.4 and 1.16.5 using protocol 754.

public static readonly ProtocolVersion MINECRAFT_1_16_4

Field Value

ProtocolVersion

MINECRAFT_1_17

Represents release 1.17 using protocol 755.

public static readonly ProtocolVersion MINECRAFT_1_17

Field Value

ProtocolVersion

MINECRAFT_1_17_1

Represents release 1.17.1 using protocol 756.

public static readonly ProtocolVersion MINECRAFT_1_17_1

Field Value

ProtocolVersion

MINECRAFT_1_18

Represents releases 1.18 and 1.18.1 using protocol 757.

public static readonly ProtocolVersion MINECRAFT_1_18

Field Value

ProtocolVersion

MINECRAFT_1_18_2

Represents release 1.18.2 using protocol 758.

public static readonly ProtocolVersion MINECRAFT_1_18_2

Field Value

ProtocolVersion

MINECRAFT_1_19

Represents release 1.19 using protocol 759.

public static readonly ProtocolVersion MINECRAFT_1_19

Field Value

ProtocolVersion

MINECRAFT_1_19_1

Represents releases 1.19.1 and 1.19.2 using protocol 760.

public static readonly ProtocolVersion MINECRAFT_1_19_1

Field Value

ProtocolVersion

MINECRAFT_1_19_3

Represents release 1.19.3 using protocol 761.

public static readonly ProtocolVersion MINECRAFT_1_19_3

Field Value

ProtocolVersion

MINECRAFT_1_19_4

Represents release 1.19.4 using protocol 762.

public static readonly ProtocolVersion MINECRAFT_1_19_4

Field Value

ProtocolVersion

MINECRAFT_1_20

Represents releases 1.20 and 1.20.1 using protocol 763.

public static readonly ProtocolVersion MINECRAFT_1_20

Field Value

ProtocolVersion

MINECRAFT_1_20_2

Represents release 1.20.2 using protocol 764.

public static readonly ProtocolVersion MINECRAFT_1_20_2

Field Value

ProtocolVersion

MINECRAFT_1_20_3

Represents Minecraft Java Edition 1.20.3 and 1.20.4, which use protocol version 765.

public static readonly ProtocolVersion MINECRAFT_1_20_3

Field Value

ProtocolVersion

MINECRAFT_1_20_5

Represents releases 1.20.5 and 1.20.6 using protocol 766.

public static readonly ProtocolVersion MINECRAFT_1_20_5

Field Value

ProtocolVersion

MINECRAFT_1_21

Represents releases 1.21 and 1.21.1 using protocol 767.

public static readonly ProtocolVersion MINECRAFT_1_21

Field Value

ProtocolVersion

MINECRAFT_1_21_11

Represents release 1.21.11 using protocol 774.

public static readonly ProtocolVersion MINECRAFT_1_21_11

Field Value

ProtocolVersion

MINECRAFT_1_21_2

Represents releases 1.21.2 and 1.21.3 using protocol 768.

public static readonly ProtocolVersion MINECRAFT_1_21_2

Field Value

ProtocolVersion

MINECRAFT_1_21_4

Represents release 1.21.4 using protocol 769.

public static readonly ProtocolVersion MINECRAFT_1_21_4

Field Value

ProtocolVersion

MINECRAFT_1_21_5

Represents Minecraft Java Edition 1.21.5, which uses protocol version 770.

public static readonly ProtocolVersion MINECRAFT_1_21_5

Field Value

ProtocolVersion

MINECRAFT_1_21_6

Represents release 1.21.6 using protocol 771.

public static readonly ProtocolVersion MINECRAFT_1_21_6

Field Value

ProtocolVersion

MINECRAFT_1_21_7

Represents releases 1.21.7 and 1.21.8 using protocol 772.

public static readonly ProtocolVersion MINECRAFT_1_21_7

Field Value

ProtocolVersion

MINECRAFT_1_21_9

Represents releases 1.21.9 and 1.21.10 using protocol 773.

public static readonly ProtocolVersion MINECRAFT_1_21_9

Field Value

ProtocolVersion

MINECRAFT_1_7_2

Represents releases 1.7.2 through 1.7.5 using protocol 4.

public static readonly ProtocolVersion MINECRAFT_1_7_2

Field Value

ProtocolVersion

MINECRAFT_1_7_6

Represents releases 1.7.6 through 1.7.10 using protocol 5.

public static readonly ProtocolVersion MINECRAFT_1_7_6

Field Value

ProtocolVersion

MINECRAFT_1_8

Represents releases 1.8 through 1.8.9 using protocol 47.

public static readonly ProtocolVersion MINECRAFT_1_8

Field Value

ProtocolVersion

MINECRAFT_1_9

Represents release 1.9 using protocol 107.

public static readonly ProtocolVersion MINECRAFT_1_9

Field Value

ProtocolVersion

MINECRAFT_1_9_1

Represents release 1.9.1 using protocol 108.

public static readonly ProtocolVersion MINECRAFT_1_9_1

Field Value

ProtocolVersion

MINECRAFT_1_9_2

Represents release 1.9.2 using protocol 109.

public static readonly ProtocolVersion MINECRAFT_1_9_2

Field Value

ProtocolVersion

MINECRAFT_1_9_3

Represents releases 1.9.3 and 1.9.4 using protocol 110.

public static readonly ProtocolVersion MINECRAFT_1_9_3

Field Value

ProtocolVersion

MINECRAFT_26_1

Represents releases 26.1 through 26.1.2 using protocol 775.

public static readonly ProtocolVersion MINECRAFT_26_1

Field Value

ProtocolVersion

Properties

FirstRelease

Gets the first associated release.

public ReleaseVersion FirstRelease { get; }

Property Value

ReleaseVersion

Exceptions

IndexOutOfRangeException

is empty.

LastRelease

Gets the last associated release.

public ReleaseVersion LastRelease { get; }

Property Value

ReleaseVersion

Exceptions

IndexOutOfRangeException

is empty.

Latest

Gets the registered protocol version with the greatest numeric identifier.

public static ProtocolVersion Latest { get; }

Property Value

ProtocolVersion

Oldest

Gets the registered protocol version with the smallest numeric identifier.

public static ProtocolVersion Oldest { get; }

Property Value

ProtocolVersion

Releases

Gets the releases associated with this protocol identifier.

public ReleaseVersion[] Releases { get; }

Property Value

ReleaseVersion[]

Value

Gets the numeric Minecraft protocol identifier.

public int Value { get; }

Property Value

int

Methods

CompareTo(object?)

Compares this version with an object by numeric protocol identifier.

public int CompareTo(object? obj)

Parameters

obj object?

A protocol version to compare, or null.

Returns

int

A positive value for null; otherwise, the comparison of numeric identifiers.

Exceptions

ArgumentException

obj is neither null nor a .

CompareTo(ProtocolVersion?)

Compares this version with another version by numeric protocol identifier.

public int CompareTo(ProtocolVersion? other)

Parameters

other ProtocolVersion?

The version to compare, or null.

Returns

int

A positive value when other is null; otherwise, a negative, zero, or positive value according to identifier ordering.

Equals(object?)

Determines whether an object is a protocol version with the same numeric identifier.

public override bool Equals(object? obj)

Parameters

obj object?

The object to compare.

Returns

bool

true for a protocol version with an equal ; otherwise, false.

From(int)

Gets a registered protocol version or creates and registers an unnamed version for an unknown identifier.

public static ProtocolVersion From(int value)

Parameters

value int

The numeric protocol identifier.

Returns

ProtocolVersion

The existing version, or a newly registered version whose array is empty.

Get(int)

Gets a previously registered protocol version by numeric identifier.

public static ProtocolVersion Get(int version)

Parameters

version int

The numeric identifier to find.

Returns

ProtocolVersion

The registered protocol-version instance.

Exceptions

KeyNotFoundException

version is not registered.

GetHashCode()

Returns the hash code of the numeric protocol identifier.

public override int GetHashCode()

Returns

int

The hash code of .

Max(ProtocolVersion, ProtocolVersion)

Returns the protocol version with the greater numeric identifier.

public static ProtocolVersion Max(ProtocolVersion version1, ProtocolVersion version2)

Parameters

version1 ProtocolVersion

The first version.

version2 ProtocolVersion

The second version.

Returns

ProtocolVersion

The greater version; when identifiers are equal, version2 is returned.

Min(ProtocolVersion, ProtocolVersion)

Returns the protocol version with the smaller numeric identifier.

public static ProtocolVersion Min(ProtocolVersion version1, ProtocolVersion version2)

Parameters

version1 ProtocolVersion

The first version.

version2 ProtocolVersion

The second version.

Returns

ProtocolVersion

The lesser version; when identifiers are equal, version2 is returned.

Range()

Enumerates every registered protocol version in ascending numeric order.

public static IEnumerable<ProtocolVersion> Range()

Returns

IEnumerable<ProtocolVersion>

The inclusive range from through .

Range(ProtocolVersion, ProtocolVersion)

Enumerates registered protocol versions between two inclusive endpoints.

public static IEnumerable<ProtocolVersion> Range(ProtocolVersion left, ProtocolVersion right)

Parameters

left ProtocolVersion

The first endpoint and the value that determines enumeration direction.

right ProtocolVersion

The second endpoint.

Returns

IEnumerable<ProtocolVersion>

Matching registered versions in ascending order when left is not greater than right; otherwise, descending order.

RangeTo(ProtocolVersion)

Enumerates registered protocol versions from this version to another version, inclusively.

public IEnumerable<ProtocolVersion> RangeTo(ProtocolVersion other)

Parameters

other ProtocolVersion

The version at the opposite end of the range.

Returns

IEnumerable<ProtocolVersion>

The registered versions between the endpoints, ascending or descending to preserve endpoint order.

ToString()

Formats the associated release span.

public override string ToString()

Returns

string

The single release name, or FirstRelease-LastRelease when multiple releases share the protocol.

Exceptions

IndexOutOfRangeException

is empty.

Operators

operator +(ProtocolVersion, int)

Moves by an index offset within the numerically sorted registered protocol versions.

public static ProtocolVersion operator +(ProtocolVersion protocolVersion, int offset)

Parameters

protocolVersion ProtocolVersion

The starting registered version.

offset int

The number of registered entries to move; negative values move toward older versions.

Returns

ProtocolVersion

The registered version at the resulting index.

Exceptions

InvalidOperationException

The resulting index is outside the registered range, including when the starting version is not registered.

operator ==(ProtocolVersion?, ProtocolVersion?)

Determines whether two protocol versions are both null or have equal numeric identifiers.

public static bool operator ==(ProtocolVersion? left, ProtocolVersion? right)

Parameters

left ProtocolVersion?

The left operand.

right ProtocolVersion?

The right operand.

Returns

bool

true when the operands are equal; otherwise, false.

operator >(ProtocolVersion, ProtocolVersion)

Determines whether one protocol identifier is greater than another.

public static bool operator >(ProtocolVersion left, ProtocolVersion right)

Parameters

left ProtocolVersion

The left operand.

right ProtocolVersion

The right operand.

Returns

bool

true when left has a greater identifier; otherwise, false.

operator >=(ProtocolVersion, ProtocolVersion)

Determines whether one protocol identifier is greater than or equal to another.

public static bool operator >=(ProtocolVersion left, ProtocolVersion right)

Parameters

left ProtocolVersion

The left operand.

right ProtocolVersion

The right operand.

Returns

bool

true when left is not less than right; otherwise, false.

operator !=(ProtocolVersion?, ProtocolVersion?)

Determines whether two protocol versions have different null state or numeric identifiers.

public static bool operator !=(ProtocolVersion? left, ProtocolVersion? right)

Parameters

left ProtocolVersion?

The left operand.

right ProtocolVersion?

The right operand.

Returns

bool

true when the operands differ; otherwise, false.

operator <(ProtocolVersion, ProtocolVersion)

Determines whether one protocol identifier is less than another.

public static bool operator <(ProtocolVersion left, ProtocolVersion right)

Parameters

left ProtocolVersion

The left operand.

right ProtocolVersion

The right operand.

Returns

bool

true when left has a smaller identifier; otherwise, false.

operator <=(ProtocolVersion, ProtocolVersion)

Determines whether left is less than or equal to right by comparing their protocol values.

public static bool operator <=(ProtocolVersion left, ProtocolVersion right)

Parameters

left ProtocolVersion

The left operand.

right ProtocolVersion

The right operand.

Returns

bool

true when left is not greater than right; otherwise, false.

operator -(ProtocolVersion, int)

Moves backward by an index offset within the registered protocol versions.

public static ProtocolVersion operator -(ProtocolVersion version, int offset)

Parameters

version ProtocolVersion

The starting registered version.

offset int

The number of registered entries to move toward older versions; negative values move toward newer versions.

Returns

ProtocolVersion

The registered version at the resulting index.

Exceptions

InvalidOperationException

The resulting index is outside the registered range, including when the starting version is not registered.