Перейти к основному содержимому

MinecraftVersion

readonly struct

Represents a Minecraft version and the protocol number that identifies it on the wire.

Declaration​

public readonly struct MinecraftVersion
NamespaceMcProtoNet.Protocol
AssemblyMcProtoNet.Protocol.dll
Sourcesrc/McProtoNet.Protocol/MinecraftVersion.cs#L13 ↗

Remarks​

Comparison and equality use the protocol number only. Two instances with the same protocol number are equal even when their names differ.

Constructors​

SignatureDescription
MinecraftVersion(int protocol, string name)Initializes a new instance of the MinecraftVersion structure with the specified protocol number and name.

MinecraftVersion(int, string)​

public MinecraftVersion(int protocol, string name)

Initializes a new instance of the MinecraftVersion structure with the specified protocol number and name.

Parameters: protocol (int), name (string)

Properties​

SignatureDescription
static IReadOnlyList<MinecraftVersion> AllVersionsGets every version declared by this type, ordered by protocol number.
static MinecraftVersion LatestGets the newest version this library supports.
string NameGets the display name of the version, such as 1.21.11 or 1.20.3–1.20.4.
int ProtocolGets the protocol number of the version.
static MinecraftVersion StartVersionGets the oldest release version this library supports.

AllVersions​

public static IReadOnlyList<MinecraftVersion> AllVersions { get; }

Gets every version declared by this type, ordered by protocol number.

The list is built once through reflection over the public static fields of this type.

Returns: IReadOnlyList<MinecraftVersion>

Latest​

public static MinecraftVersion Latest { get; }

Gets the newest version this library supports.

Returns: MinecraftVersion

Name​

public string Name { get; }

Gets the display name of the version, such as 1.21.11 or 1.20.3–1.20.4.

Returns: string

Protocol​

public int Protocol { get; }

Gets the protocol number of the version.

Returns: int

StartVersion​

public static MinecraftVersion StartVersion { get; }

Gets the oldest release version this library supports.

Returns: MinecraftVersion

Fields​

SignatureDescription
const int LatestProtocol = 777The highest protocol number this library supports.
const int StartProtocol = 735The lowest protocol number this library supports.
static MinecraftVersion V1_16Minecraft 1.16, protocol 735.
static MinecraftVersion V1_16_1Minecraft 1.16.1, protocol 736.
static MinecraftVersion V1_16_2Minecraft 1.16.2, protocol 751.
static MinecraftVersion V1_16_2_Pre1Minecraft 1.16.2-pre1, protocol 744.
static MinecraftVersion V1_16_2_Pre2Minecraft 1.16.2-pre2, protocol 746.
static MinecraftVersion V1_16_2_Pre3Minecraft 1.16.2-pre3, protocol 748.
static MinecraftVersion V1_16_2_Rc1Minecraft 1.16.2-rc1, protocol 749.
static MinecraftVersion V1_16_2_Rc2Minecraft 1.16.2-rc2, protocol 750.
static MinecraftVersion V1_16_2_Snapshot_20w27aThe 1.16.2 snapshot 20w27a, protocol 738.
static MinecraftVersion V1_16_2_Snapshot_20w28aThe 1.16.2 snapshot 20w28a, protocol 740.
static MinecraftVersion V1_16_2_Snapshot_20w29aThe 1.16.2 snapshot 20w29a, protocol 741.
static MinecraftVersion V1_16_2_Snapshot_20w30aThe 1.16.2 snapshot 20w30a, protocol 743.
static MinecraftVersion V1_16_3Minecraft 1.16.3, protocol 753.
static MinecraftVersion V1_16_3_Rc1Minecraft 1.16.3-rc1, protocol 752.
static MinecraftVersion V1_16_4_To_1_16_5Minecraft 1.16.4 through 1.16.5, protocol 754.
const int V1_16_Protocol = 735The protocol number of Minecraft 1.16.
static MinecraftVersion V1_17Minecraft 1.17, protocol 755.
static MinecraftVersion V1_17_1Minecraft 1.17.1, protocol 756.
static MinecraftVersion V1_18_2Minecraft 1.18.2, protocol 758.
static MinecraftVersion V1_18_To_1_18_1Minecraft 1.18 through 1.18.1, protocol 757.
static MinecraftVersion V1_19Minecraft 1.19, protocol 759.
static MinecraftVersion V1_19_2Minecraft 1.19.2, protocol 760.
static MinecraftVersion V1_19_3Minecraft 1.19.3, protocol 761.
static MinecraftVersion V1_19_4Minecraft 1.19.4, protocol 762.
static MinecraftVersion V1_20_2Minecraft 1.20.2, protocol 764.
static MinecraftVersion V1_20_3_To_1_20_4Minecraft 1.20.3 through 1.20.4, protocol 765.
static MinecraftVersion V1_20_5_To_1_20_6Minecraft 1.20.5 through 1.20.6, protocol 766.
static MinecraftVersion V1_20_To_1_20_1Minecraft 1.20 through 1.20.1, protocol 763.
static MinecraftVersion V1_21_11Minecraft 1.21.11, protocol 774.
const int V1_21_11_Protocol = 774The protocol number of Minecraft 1.21.11.
static MinecraftVersion V1_21_3Minecraft 1.21.3, protocol 768.
static MinecraftVersion V1_21_4Minecraft 1.21.4, protocol 769.
static MinecraftVersion V1_21_5Minecraft 1.21.5, protocol 770.
static MinecraftVersion V1_21_6Minecraft 1.21.6, protocol 771.
static MinecraftVersion V1_21_7_To_1_21_8Minecraft 1.21.7 through 1.21.8, protocol 772.
const int V1_21_7_To_1_21_8_Protocol = 772The protocol number of Minecraft 1.21.7 through 1.21.8.
static MinecraftVersion V1_21_9_To_1_21_10Minecraft 1.21.9 through 1.21.10, protocol 773.
const int V1_21_9_To_1_21_10_Protocol = 773The protocol number of Minecraft 1.21.9 through 1.21.10.
static MinecraftVersion V1_21_To_1_21_1Minecraft 1.21 through 1.21.1, protocol 767.
static MinecraftVersion V26_1_To_26_1_2Minecraft 26.1 through 26.1.2, protocol 775.
const int V26_1_To_26_1_2_Protocol = 775The protocol number of Minecraft 26.1 through 26.1.2.
static MinecraftVersion V26_2Minecraft 26.2, protocol 776.
const int V26_2_Protocol = 776The protocol number of Minecraft 26.2.
static MinecraftVersion V26_3Minecraft 26.3, protocol 777.
const int V26_3_Protocol = 777The protocol number of Minecraft 26.3.

LatestProtocol​

public const int LatestProtocol = 777

The highest protocol number this library supports.

Returns: int

StartProtocol​

public const int StartProtocol = 735

The lowest protocol number this library supports.

Returns: int

V1_16​

public static readonly MinecraftVersion V1_16

Minecraft 1.16, protocol 735.

Returns: MinecraftVersion

V1_16_1​

public static readonly MinecraftVersion V1_16_1

Minecraft 1.16.1, protocol 736.

Returns: MinecraftVersion

V1_16_2​

public static readonly MinecraftVersion V1_16_2

Minecraft 1.16.2, protocol 751.

Returns: MinecraftVersion

V1_16_2_Pre1​

public static readonly MinecraftVersion V1_16_2_Pre1

Minecraft 1.16.2-pre1, protocol 744.

Returns: MinecraftVersion

V1_16_2_Pre2​

public static readonly MinecraftVersion V1_16_2_Pre2

Minecraft 1.16.2-pre2, protocol 746.

Returns: MinecraftVersion

V1_16_2_Pre3​

public static readonly MinecraftVersion V1_16_2_Pre3

Minecraft 1.16.2-pre3, protocol 748.

Returns: MinecraftVersion

V1_16_2_Rc1​

public static readonly MinecraftVersion V1_16_2_Rc1

Minecraft 1.16.2-rc1, protocol 749.

Returns: MinecraftVersion

V1_16_2_Rc2​

public static readonly MinecraftVersion V1_16_2_Rc2

Minecraft 1.16.2-rc2, protocol 750.

Returns: MinecraftVersion

V1_16_2_Snapshot_20w27a​

public static readonly MinecraftVersion V1_16_2_Snapshot_20w27a

The 1.16.2 snapshot 20w27a, protocol 738.

Returns: MinecraftVersion

V1_16_2_Snapshot_20w28a​

public static readonly MinecraftVersion V1_16_2_Snapshot_20w28a

The 1.16.2 snapshot 20w28a, protocol 740.

Returns: MinecraftVersion

V1_16_2_Snapshot_20w29a​

public static readonly MinecraftVersion V1_16_2_Snapshot_20w29a

The 1.16.2 snapshot 20w29a, protocol 741.

Returns: MinecraftVersion

V1_16_2_Snapshot_20w30a​

public static readonly MinecraftVersion V1_16_2_Snapshot_20w30a

The 1.16.2 snapshot 20w30a, protocol 743.

Returns: MinecraftVersion

V1_16_3​

public static readonly MinecraftVersion V1_16_3

Minecraft 1.16.3, protocol 753.

Returns: MinecraftVersion

V1_16_3_Rc1​

public static readonly MinecraftVersion V1_16_3_Rc1

Minecraft 1.16.3-rc1, protocol 752.

Returns: MinecraftVersion

V1_16_4_To_1_16_5​

public static readonly MinecraftVersion V1_16_4_To_1_16_5

Minecraft 1.16.4 through 1.16.5, protocol 754.

Returns: MinecraftVersion

V1_16_Protocol​

public const int V1_16_Protocol = 735

The protocol number of Minecraft 1.16.

Returns: int

V1_17​

public static readonly MinecraftVersion V1_17

Minecraft 1.17, protocol 755.

Returns: MinecraftVersion

V1_17_1​

public static readonly MinecraftVersion V1_17_1

Minecraft 1.17.1, protocol 756.

Returns: MinecraftVersion

V1_18_2​

public static readonly MinecraftVersion V1_18_2

Minecraft 1.18.2, protocol 758.

Returns: MinecraftVersion

V1_18_To_1_18_1​

public static readonly MinecraftVersion V1_18_To_1_18_1

Minecraft 1.18 through 1.18.1, protocol 757.

Returns: MinecraftVersion

V1_19​

public static readonly MinecraftVersion V1_19

Minecraft 1.19, protocol 759.

Returns: MinecraftVersion

V1_19_2​

public static readonly MinecraftVersion V1_19_2

Minecraft 1.19.2, protocol 760.

Returns: MinecraftVersion

V1_19_3​

public static readonly MinecraftVersion V1_19_3

Minecraft 1.19.3, protocol 761.

Returns: MinecraftVersion

V1_19_4​

public static readonly MinecraftVersion V1_19_4

Minecraft 1.19.4, protocol 762.

Returns: MinecraftVersion

V1_20_2​

public static readonly MinecraftVersion V1_20_2

Minecraft 1.20.2, protocol 764.

Returns: MinecraftVersion

V1_20_3_To_1_20_4​

public static readonly MinecraftVersion V1_20_3_To_1_20_4

Minecraft 1.20.3 through 1.20.4, protocol 765.

Returns: MinecraftVersion

V1_20_5_To_1_20_6​

public static readonly MinecraftVersion V1_20_5_To_1_20_6

Minecraft 1.20.5 through 1.20.6, protocol 766.

Returns: MinecraftVersion

V1_20_To_1_20_1​

public static readonly MinecraftVersion V1_20_To_1_20_1

Minecraft 1.20 through 1.20.1, protocol 763.

Returns: MinecraftVersion

V1_21_11​

public static readonly MinecraftVersion V1_21_11

Minecraft 1.21.11, protocol 774.

Returns: MinecraftVersion

V1_21_11_Protocol​

public const int V1_21_11_Protocol = 774

The protocol number of Minecraft 1.21.11.

Returns: int

V1_21_3​

public static readonly MinecraftVersion V1_21_3

Minecraft 1.21.3, protocol 768.

Returns: MinecraftVersion

V1_21_4​

public static readonly MinecraftVersion V1_21_4

Minecraft 1.21.4, protocol 769.

Returns: MinecraftVersion

V1_21_5​

public static readonly MinecraftVersion V1_21_5

Minecraft 1.21.5, protocol 770.

Returns: MinecraftVersion

V1_21_6​

public static readonly MinecraftVersion V1_21_6

Minecraft 1.21.6, protocol 771.

Returns: MinecraftVersion

V1_21_7_To_1_21_8​

public static readonly MinecraftVersion V1_21_7_To_1_21_8

Minecraft 1.21.7 through 1.21.8, protocol 772.

Returns: MinecraftVersion

V1_21_7_To_1_21_8_Protocol​

public const int V1_21_7_To_1_21_8_Protocol = 772

The protocol number of Minecraft 1.21.7 through 1.21.8.

Returns: int

V1_21_9_To_1_21_10​

public static readonly MinecraftVersion V1_21_9_To_1_21_10

Minecraft 1.21.9 through 1.21.10, protocol 773.

Returns: MinecraftVersion

V1_21_9_To_1_21_10_Protocol​

public const int V1_21_9_To_1_21_10_Protocol = 773

The protocol number of Minecraft 1.21.9 through 1.21.10.

Returns: int

V1_21_To_1_21_1​

public static readonly MinecraftVersion V1_21_To_1_21_1

Minecraft 1.21 through 1.21.1, protocol 767.

Returns: MinecraftVersion

V26_1_To_26_1_2​

public static readonly MinecraftVersion V26_1_To_26_1_2

Minecraft 26.1 through 26.1.2, protocol 775.

Returns: MinecraftVersion

V26_1_To_26_1_2_Protocol​

public const int V26_1_To_26_1_2_Protocol = 775

The protocol number of Minecraft 26.1 through 26.1.2.

Returns: int

V26_2​

public static readonly MinecraftVersion V26_2

Minecraft 26.2, protocol 776.

Returns: MinecraftVersion

V26_2_Protocol​

public const int V26_2_Protocol = 776

The protocol number of Minecraft 26.2.

Returns: int

V26_3​

public static readonly MinecraftVersion V26_3

Minecraft 26.3, protocol 777.

Returns: MinecraftVersion

V26_3_Protocol​

public const int V26_3_Protocol = 777

The protocol number of Minecraft 26.3.

Returns: int

Methods​

SignatureDescription
int CompareTo(MinecraftVersion other)Compares the current instance with another MinecraftVersion and returns their relative order by protocol number.
bool Equals(MinecraftVersion other)Determines whether the current instance and another MinecraftVersion have the same protocol number.
bool Equals(object? obj)Determines whether the specified object is a MinecraftVersion with the same protocol number as the current instance.
static MinecraftVersion FromProtocol(int protocol)Returns the version that corresponds to the specified protocol number.
int GetHashCode()Returns the hash code for the current instance.
int ToInt32()Returns the protocol number of the version as a 32-bit signed integer.
string ToString()Returns the string representation of the version.

CompareTo(MinecraftVersion)​

public int CompareTo(MinecraftVersion other)

Compares the current instance with another MinecraftVersion and returns their relative order by protocol number.

Parameters: other (MinecraftVersion)

Returns: int - A value less than zero if this instance precedes other; zero if both have the same protocol number; a value greater than zero if this instance follows other.

Equals(MinecraftVersion)​

public bool Equals(MinecraftVersion other)

Determines whether the current instance and another MinecraftVersion have the same protocol number.

Parameters: other (MinecraftVersion)

Returns: bool - true if both have the same protocol number; otherwise, false.

Equals(object?)​

public override bool Equals(object? obj)

Determines whether the specified object is a MinecraftVersion with the same protocol number as the current instance.

Parameters: obj (object)

Returns: bool - true if obj is a MinecraftVersion with the same protocol number; otherwise, false.

FromProtocol(int)​

public static MinecraftVersion FromProtocol(int protocol)

Returns the version that corresponds to the specified protocol number.

Protocol numbers of 1.16.2 snapshots, pre-releases and release candidates map to MinecraftVersion.V1_16_2, and the protocol number of 1.16.3-rc1 maps to MinecraftVersion.V1_16_3.

Parameters: protocol (int)

Returns: MinecraftVersion - The MinecraftVersion associated with protocol.

Exceptions: NotSupportedException - protocol is not a known protocol number.

GetHashCode()​

public override int GetHashCode()

Returns the hash code for the current instance.

Returns: int - The protocol number of the version.

ToInt32()​

public int ToInt32()

Returns the protocol number of the version as a 32-bit signed integer.

Returns: int - The protocol number of the version.

ToString()​

public override string ToString()

Returns the string representation of the version.

Returns: string - The name of the version followed by its protocol number.

Operators​

SignatureDescription
static bool operator ==(MinecraftVersion left, MinecraftVersion right)Determines whether two specified versions have the same protocol number.
static bool operator >(MinecraftVersion left, MinecraftVersion right)Determines whether the protocol number of one version is greater than that of another version.
static bool operator >=(MinecraftVersion left, MinecraftVersion right)Determines whether the protocol number of one version is greater than or equal to that of another version.
static implicit operator int(MinecraftVersion v)Converts a MinecraftVersion to its protocol number.
static bool operator !=(MinecraftVersion left, MinecraftVersion right)Determines whether two specified versions have different protocol numbers.
static bool operator <(MinecraftVersion left, MinecraftVersion right)Determines whether the protocol number of one version is less than that of another version.
static bool operator <=(MinecraftVersion left, MinecraftVersion right)Determines whether the protocol number of one version is less than or equal to that of another version.

operator ==(MinecraftVersion, MinecraftVersion)​

public static bool operator ==(MinecraftVersion left, MinecraftVersion right)

Determines whether two specified versions have the same protocol number.

Parameters: left (MinecraftVersion), right (MinecraftVersion)

Returns: bool - true if both have the same protocol number; otherwise, false.

operator >(MinecraftVersion, MinecraftVersion)​

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

Determines whether the protocol number of one version is greater than that of another version.

Parameters: left (MinecraftVersion), right (MinecraftVersion)

Returns: bool - true if the protocol number of left is greater than that of right; otherwise, false.

operator >=(MinecraftVersion, MinecraftVersion)​

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

Determines whether the protocol number of one version is greater than or equal to that of another version.

Parameters: left (MinecraftVersion), right (MinecraftVersion)

Returns: bool - true if the protocol number of left is greater than or equal to that of right; otherwise, false.

implicit operator int(MinecraftVersion)​

public static implicit operator int(MinecraftVersion v)

Converts a MinecraftVersion to its protocol number.

Parameters: v (MinecraftVersion)

Returns: int - The protocol number of v.

operator !=(MinecraftVersion, MinecraftVersion)​

public static bool operator !=(MinecraftVersion left, MinecraftVersion right)

Determines whether two specified versions have different protocol numbers.

Parameters: left (MinecraftVersion), right (MinecraftVersion)

Returns: bool - true if the protocol numbers differ; otherwise, false.

operator <(MinecraftVersion, MinecraftVersion)​

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

Determines whether the protocol number of one version is less than that of another version.

Parameters: left (MinecraftVersion), right (MinecraftVersion)

Returns: bool - true if the protocol number of left is less than that of right; otherwise, false.

operator <=(MinecraftVersion, MinecraftVersion)​

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

Determines whether the protocol number of one version is less than or equal to that of another version.

Parameters: left (MinecraftVersion), right (MinecraftVersion)

Returns: bool - true if the protocol number of left is less than or equal to that of right; otherwise, false.