3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00
Dieser Commit ist enthalten in:
Shane Freeder 2022-06-08 23:59:33 +01:00
Ursprung 51dc67f44b
Commit 4599d15003
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: A3F61EA5A085289C
3 geänderte Dateien mit 34 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -34,6 +34,7 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.velocitypowered.api.network.ProtocolVersion;
import java.util.List;
import net.kyori.adventure.nbt.BinaryTag;
import net.kyori.adventure.nbt.CompoundBinaryTag;
import net.kyori.adventure.nbt.ListBinaryTag;
import net.kyori.adventure.text.format.NamedTextColor;
@ -49,8 +50,16 @@ public class ChatData {
private final String identifier;
private final int id;
private final Decoration chatDecoration;
private Decoration narrationDecoration;
private final Decoration narrationDecoration;
/**
* Represents a ChatRegistry entry.
*
* @param id chat type id
* @param identifier chat type identifier
* @param chatDecoration chat decoration
* @param narrationDecoration narration decoration
*/
public ChatData(int id, String identifier, Decoration chatDecoration, Decoration narrationDecoration) {
this.id = id;
this.identifier = identifier;
@ -105,7 +114,14 @@ public class ChatData {
return id;
}
/**
* Encodes the chat data for the network.
* @param version The protocol version to encode this chat data for
* @return The encoded data structure
*/
public CompoundBinaryTag encodeAsCompoundTag(ProtocolVersion version) {
return null;
}
public static class Decoration implements Translatable {

Datei anzeigen

@ -52,7 +52,16 @@ public final class ChatRegistry {
return builder.build();
}
public BinaryTag build() {
return null;
/**
* Serialises the Chat Registry for sending over the network.
* @param version the version to encode for
* @return The serialised tag list
*/
public ListBinaryTag encodeRegistry(ProtocolVersion version) {
final ListBinaryTag.Builder<BinaryTag> builder = ListBinaryTag.builder();
for (ChatData data : registeredChatTypes.values()) {
builder.add(data.encodeAsCompoundTag(version));
}
return builder.build();
}
}

Datei anzeigen

@ -393,7 +393,11 @@ public class JoinGame implements MinecraftPacket {
registryContainer.put("minecraft:dimension_type", dimensionRegistryEntry.build());
registryContainer.put("minecraft:worldgen/biome", biomeRegistry);
if (version.compareTo(ProtocolVersion.MINECRAFT_1_19) >= 0) {
registryContainer.put("minecraft:chat_type", chatTypeRegistry.build());
final ListBinaryTag encodedChatRegistry = chatTypeRegistry.encodeRegistry(version);
CompoundBinaryTag.Builder chatRegistryEntry = CompoundBinaryTag.builder();
chatRegistryEntry.putString("type", "minecraft:chat_type");
chatRegistryEntry.put("value", encodedChatRegistry);
registryContainer.put("minecraft:chat_type", encodedChatRegistry);
}
} else {
registryContainer.put("dimension", encodedDimensionRegistry);