Skip to content

Class ByteTag

Namespace: Void.Minecraft.Nbt
Assembly: Void.Minecraft.dll

A tag that contains a single 8-bit integer value.

[Serializable]
public class ByteTag : NumericTag<byte>, IEquatable<Tag>, ICloneable, IEquatable<NumericTag<byte>>, IComparable<NumericTag<byte>>, IComparable

Inheritance

objectTagNumericTag<byte>ByteTag

Implements

IEquatable<Tag>, ICloneable, IEquatable<NumericTag<byte>>, IComparable<NumericTag<byte>>, IComparable

Inherited Members

NumericTag<byte>.Value, NumericTag<byte>.Equals(NumericTag<byte>?), NumericTag<byte>.Equals(object?), NumericTag<byte>.GetHashCode(), NumericTag<byte>.CompareTo(NumericTag<byte>?), NumericTag<byte>.CompareTo(object?), Tag.NoName, Tag.Type, Tag.Parent, Tag.Name, Tag.PrettyPrinted(StringBuilder, int, string), Tag.PrettyName, Tag.WriteJson(Utf8JsonWriter, bool), Tag.WriteJson(Stream, JsonWriterOptions?), Tag.WriteJsonAsync(Stream, JsonWriterOptions?), Tag.ToJson(JsonWriterOptions?), Tag.ToJsonString(bool, string), Tag.Equals(Tag?), Tag.Equals(object?), Tag.GetHashCode(), Tag.Clone(), Tag.Stringify(bool), Tag.StringifyName, object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Remarks

While this class uses the CLS compliant (0..255), the NBT specification uses a signed value with a range of -128..127. It is recommended to use the property if your language supports a signed 8-bit value, otherwise simply ensure the bits are equivalent.

Constructors

ByteTag(string?, byte)

Creates a new instance of the class with the specified value.

public ByteTag(string? name, byte value)

Parameters

name string?

The name of the tag, or null if tag has no name.

value byte

The value to assign to this tag.

ByteTag(string?, int)

Creates a new instance of the class with the specified value.

public ByteTag(string? name, int value)

Parameters

name string?

The name of the tag, or null if tag has no name.

value int

The value to assign to this tag.

Remarks

The use of is for convenience only.

ByteTag(string?, bool)

Creates a new instance of the class with the specified value.

public ByteTag(string? name, bool value)

Parameters

name string?

The name of the tag, or null if tag has no name.

value bool

The value to assign to this tag.

ByteTag(string?, sbyte)

Creates a new instance of the class with the specified value.

public ByteTag(string? name, sbyte value)

Parameters

name string?

The name of the tag, or null if tag has no name.

value sbyte

The value to assign to this tag.

Properties

Bool

Gets or sets the value of this tag as a boolean value.

public bool Bool { get; set; }

Property Value

bool

IsBool

Gets a flag indicating if this was assigned a value.

public bool IsBool { get; }

Property Value

bool

SignedValue

Gets or sets the value of this tag as an unsigned value.

public sbyte SignedValue { get; set; }

Property Value

sbyte

Remarks

This is only a reinterpretation of the bytes, no actual conversion is performed.

Value

public byte Value { get; set; }

Property Value

byte

Methods

Stringify(bool)

Gets the string representation of this NBT tag (SNBT).

public override string Stringify(bool named = true)

Parameters

named bool

Flag indicating if the name of the tag should be written.

Returns

string

This NBT tag in SNBT format.

See Also

https://minecraft.fandom.com/wiki/NBT_format#SNBT_format

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

WriteJson(Utf8JsonWriter, bool)

Uses the provided writer to write the NBT tag in JSON format.

protected override void WriteJson(Utf8JsonWriter writer, bool named = true)

Parameters

writer Utf8JsonWriter

A JSON writer instance.

named bool

Flag indicating if this object’s name should be written as a property name, or false when it is a child of , in which case it should be written as a JSON array element.

Operators

implicit operator byte(ByteTag)

Implicit conversion of this tag to a .

public static implicit operator byte(ByteTag tag)

Parameters

tag ByteTag

The tag to convert.

Returns

byte

The tag represented as a .

implicit operator bool(ByteTag)

Implicit conversion of this tag to a .

public static implicit operator bool(ByteTag tag)

Parameters

tag ByteTag

The tag to convert.

Returns

bool

The tag represented as a .

implicit operator sbyte(ByteTag)

Implicit conversion of this tag to a .

public static implicit operator sbyte(ByteTag tag)

Parameters

tag ByteTag

The tag to convert.

Returns

sbyte

The tag represented as a .