code: public static void writeTag(DataOutput out, Tag tag) throws IOException {
          out.writeByte(TagRegistry.getIdFor(tag.getClass()));
          out.writeUTF(tag.getName());
          tag.write(out);
      }
docs: Writes an NBT tag.
  
  @param out Data output to write to.
  @param tag Tag to write.
  @throws java.io.IOException If an I/O error occurs.