KyoriPowered / adventure

A user-interface library, formerly known as text, for Minecraft: Java Edition
https://docs.advntr.dev/
MIT License
679 stars 104 forks source link

Tag writer is outdated for packets #988

Closed Snowbelldog closed 8 months ago

Snowbelldog commented 8 months ago

After some trial and error and constant kicks I have now found out that there is an update in NBT which have not yet been updated in adventure. Well I've been sitting on it for some time now because I almost didn't think it was possible.

Here is the link to the protocol wiki: https://wiki.vg/NBT#Network_NBT_(Java_Edition) in net.kyori.adventure.nbt.BinaryTagWriterImpl

public void write(final @NotNull CompoundBinaryTag tag, final @NotNull DataOutput output) throws IOException {
     output.writeByte(BinaryTagTypes.COMPOUND.id());
     output.writeUTF("");
     BinaryTagTypes.COMPOUND.write(tag, output);
}

new or a second method

public void write(final @NotNull CompoundBinaryTag tag, final @NotNull DataOutput output, ?VersionIdentifier?) throws IOException {
    output.writeByte(BinaryTagTypes.COMPOUND.id());
    if(?VersionIdentifier? < 1_20_2)
        writeShort(0); //or output.writeUTF(""); for more calculation steps
    BinaryTagTypes.COMPOUND.write(tag, output);
}
zml2008 commented 8 months ago

Duplicate of #968