Class Component
Namespace: Void.Minecraft.Components.Text
Assembly: Void.Minecraft.dll
public record Component : IEquatable<Component>Inheritance
Implements
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Constructors
Component(IContent, Children, Formatting, Interactivity)
public Component(IContent Content, Children Children, Formatting Formatting, Interactivity Interactivity)Parameters
Content IContent
Children Children
Formatting Formatting
Interactivity Interactivity
Properties
AsText
Returns a string representation of the component.
public string AsText { get; }Property Value
Children
public Children Children { get; init; }Property Value
Content
public IContent Content { get; init; }Property Value
Default
Represents a default component initialized with empty text content, default children, formatting, and interactivity.
public static Component Default { get; }Property Value
Formatting
public Formatting Formatting { get; init; }Property Value
Interactivity
public Interactivity Interactivity { get; init; }Property Value
Methods
DeserializeJson(JsonNode)
Deserializes a JSON node into a Component object.
public static Component DeserializeJson(JsonNode source)Parameters
source JsonNode
The JSON node containing the data to be deserialized into a Component.
Returns
Returns a Component object created from the provided JSON data.
DeserializeLegacy(string, char)
Deserializes a string into a Component object using legacy serialization.
public static Component DeserializeLegacy(string source, char prefix = '&')Parameters
source string
The string representation of the Component to be deserialized.
prefix char
The character used to identify properties in the string representation.
Returns
Returns a deserialized Component object.
DeserializeNbt(NbtTag)
Deserializes an NBT tag into a Component object.
public static Component DeserializeNbt(NbtTag tag)Parameters
tag NbtTag
The NBT tag that contains the data to be deserialized into a Component.
Returns
Returns a Component object created from the provided NBT tag.
DeserializeSnbt(string)
Deserializes a string representation of SNBT into a Component object.
public static Component DeserializeSnbt(string source)Parameters
source string
The string representation of SNBT that needs to be converted into a Component.
Returns
Returns a Component object created from the deserialized SNBT data.
ReadFrom<TBuffer>(ref TBuffer, bool)
Reads data from a buffer and deserializes it.
public static Component ReadFrom<TBuffer>(ref TBuffer buffer, bool readName = true) where TBuffer : struct, IMinecraftBuffer<TBuffer>, allows ref structParameters
buffer TBuffer
This parameter is the source from which data is read and processed for deserialization.
readName bool
Returns
The method returns a Component object created from the deserialized data.
Type Parameters
TBuffer
This type parameter represents a structure that implements a specific buffer interface for reading data.
ReadFrom(ref MinecraftBuffer, bool)
Reads data from a buffer and deserializes it into a Component.
public static Component ReadFrom(ref MinecraftBuffer buffer, bool readName = true)Parameters
buffer MinecraftBuffer
The buffer containing the data to be read and deserialized into a Component.
readName bool
Returns
Returns a Component object created from the data in the buffer.
SerializeJson()
Serializes the current component to JSON format.
public JsonNode SerializeJson()Returns
Returns a JsonNode representing the serialized component.
SerializeLegacy(char)
Serializes the current object to Legacy format.
public string SerializeLegacy(char prefix = '&')Parameters
prefix char
Specifies the prefix of the formatting codes to be used during serialization.
Returns
Returns a Legacy string representing the serialized object.
SerializeNbt()
Serializes the current component into NBT format.
public NbtTag SerializeNbt()Returns
Returns the serialized NBT tag representation of the component.
SerializeSnbt()
Serializes the current component into SNBT format.
public string SerializeSnbt()Returns
Returns the serialized data in SNBT format.
ToString()
Converts the object to its string representation by serializing it to SNBT format. version.
public override string ToString()Returns
Returns the string representation of the serialized NBT data.
WriteTo(ref MinecraftBuffer, bool)
Writes serialized data to a buffer.
public void WriteTo(ref MinecraftBuffer buffer, bool writeName = true)Parameters
buffer MinecraftBuffer
The buffer is used to store serialized data.
writeName bool
A boolean parameter that indicates whether to include the name when writing the tag to the buffer. Default is true.
WriteTo<TBuffer>(ref TBuffer, bool)
Writes serialized data to a buffer.
public void WriteTo<TBuffer>(ref TBuffer buffer, bool writeName = true) where TBuffer : struct, IMinecraftBuffer<TBuffer>, allows ref structParameters
buffer TBuffer
This parameter is the destination where the serialized data will be written.
writeName bool
A boolean parameter that indicates whether to include the name when writing the tag to the buffer. Default is true.
Type Parameters
TBuffer
This type parameter represents a structure that implements a specific buffer interface for writing data.
Operators
implicit operator Component(string)
public static implicit operator Component(string text)Parameters
text string