Fix writing non-compound root NBT tags

This commit is contained in:
md_5 2023-10-14 16:36:45 +11:00
parent a7dbbc2f0a
commit c8568764f6
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -325,9 +325,18 @@ public abstract class DefinedPacket
public static void writeTag(Tag tag, ByteBuf output, int protocolVersion) public static void writeTag(Tag tag, ByteBuf output, int protocolVersion)
{ {
DataOutputStream out = new DataOutputStream( new ByteBufOutputStream( output ) );
try try
{ {
tag.write( new DataOutputStream( new ByteBufOutputStream( output ) ) ); if ( tag instanceof SpecificTag )
{
SpecificTag specificTag = (SpecificTag) tag;
specificTag.writeType( out );
specificTag.write( out );
} else
{
tag.write( out );
}
} catch ( IOException ex ) } catch ( IOException ex )
{ {
throw new RuntimeException( "Exception writing tag", ex ); throw new RuntimeException( "Exception writing tag", ex );